Skip to main content

k3s using docker runtime

install single-node k3s cluster instead of containerd

I can install with these commands on debian buster arm64 though can not on bullseye.

at first intall docker

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo docker run hello-world

then install k3

curl -sfL https://get.k3s.io | sh -s - --docker
systemctl status k3s

uninstall

/usr/local/bin/k3s-uninstall.sh

create deployment

create yaml file

cat <<EOF > nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx-test
        image: nginx-test:latest
        imagePullPolicy: Never
        ports:
        - containerPort: 80
EOF

create and confirm the deployment

sudo kubectl create -f nginx-deployment.yaml
sudo kubectl get deploy
sudo kubectl get pod
sudo kubectl exec -it <pod name> -- curl localhost

create service

create yaml file

cat <<EOF > nginx-service.yaml
kind: Service
apiVersion: v1
metadata:
  name: my-service
spec:
  type: NodePort
  selector:
    app: nginx
  ports:
  - protocol: TCP
    targetPort: 80
    port: 80

create and confirm the service

sudo kubectl create -f nginx-service.yaml
sudo kubectl get svc
curl x.x.x.x

modify service

sudo kubectl apply -f nginx-deployment.yaml
sudo kubectl get svc

delete srvice

sudo kubectl delete svc <service name>

delete deployment

sudo kubectl delete -f ./nginx-deployment.yaml

Bluetooth tethering on Windows10

connect

  1. Pairing
  2. To open Bluetooth Personal Area Network Device, right click the blootooth icon in the system tray and click Join a Personal Area Network. You can create a shortcut to it where you like.
  3. Right click the icon of your router device and select Connect using then click Access Point

If you use an iphone as your router device, you don't have to tap 'internet sharing' when you start bluetooth tethering.

disconnect

  1. Open Bluetooth Personal Area Network Device
  2. Right click the icon of your router device and click disconnect

data usage limit

When we use wifi on windows, we have configuration for metered connection but we don't generally when blootooth pan.

I heard that it would be possible to limit data usage by editing registry.

  1. run regedit
  2. open HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\DefaultMediaCost
  3. get full control of it for administrators
  4. change value of Ethernet to 2
  5. restart windows

This configures also ethernet to metered connection.

Grandstream GXP1610

GXP1610 は 1SIP 対応の IP電話機。 液晶バックライトを搭載してたり、2SIPに対応していたり、PoE対応、Gigabit Ethernet対応してるような上級機がある中の入門機。

以下、備忘録

  • 説明書はペラペラ。必要な情報は自ら取りに行く姿勢が求められる
  • スタンドの取り付け向きに注意
  • スイッチからのケーブルをLANに、PCへのケーブルをPCへ接続すると、ハブ(?)として動作してくれる(10/100Mbps)
  • DHCPが有効なネットワークに接続してほどなくするとIPアドレスを取れる
  • ディスプレイにIPアドレスが表示されるので、PCからWebアクセスすると、管理画面を表示できる
  • 管理画面の初期パスワードは同梱の説明書に記載されている。初めてログインすると変更が促される。ログイン時に5回間違えるとやばい
  • Web UI、端末の液晶とも、多言語対応(日本語表示可能)
  • 試していないがIPアドレスは静的アドレスを設定可能なようだ
  • 設定済みのAsteriskに収容するだけなら、Web UI で SIPサーバ、ID、パスワード等を設定するだけなので、簡単
  • SIPアカウント設定の画面で、Voice Mail Access Number を設定すると、メールアイコンのボタンを押すことで、VoiceMail に架電することができる
  • NTPサーバを指定できる
  • Syslog転送できる(facility=user)
  • 試していないけど、SNMPサーバを指定できるようだ
  • 試していないけど、LDAPの電話帳が使えるようだ

rpm package management

list installed packages

# rpm -qa [package name]
# yum list [package name]
# dnf list [package name]

install package / rpm file

# rpm -ivh <rpm file name>
# microdnf install <package name>
# dnf install <package name>

list installed files

# rpm -ql <package name>

list repositories

# yum repolist [repository name] [-v]
# microdnf repolist
# dnf repolist [repository name] [-v]

show packages contained in the repository

# yum repository-packages [repository name] list
# dnf repository-packages [repository name] list

disable or enable repository with config-manager module contained in yum-utils

# yum config-manager <--set-disabled|--set-enabled> epel
# dnf config-manager <--set-disabled|--set-enabled> epel

update installed packages

# yum update
# microdnf update
# dnf update

download rpm file with yumdownloader which is a part of yum-utils package.

# yumdownloder <package name>
# yumdownloder <package name>.<version>.<architecture>

list files contained in a rpm file

# rpm2cpio <rpm file> | cpio --list

extract a rpm file in the current directory

# rpm2cpio <rpm file> | cpio -id
# find . -type f

remove installed package

# rpm -e <pakcage name>
# yum remove <pakcage name>
# microdnf remove <pakcage name>
# dnf remove <pakcage name>

remove all cached data

# yum clean all
# microdnf clean
# dnf clean all

show transaction history

# yum history
# dnf history

riding bicycle

間違いだらけの自転車の乗り方

「チャリは全部同じ。短い距離ですぐにつかれる」は誤り

まず、チャリ(またはチャリンコ)という呼び方は、侮蔑を含んでいるように感じる。正当に評価していない感じがして、好きではない。

自転車は車種や乗り方次第で、いろんな可能性がある。 自分の目的に合わない車種、体に合わないサイズを選択したり、不適切なセッティングでは、自転車の可能性を発揮できない。 シティサイクルでも車道を颯爽と走りたいなら、(セミ)アップタイプのハンドルではなく、前傾姿勢がとりやすいバータイプを選択すると、案外と早く遠くまで快適に走ることができるだろう。

「自転車は欠点ばかりで、良いところがなにもない」は誤り

上り坂、向かい風、雨、雪がつらいのは否定できない。 昨今の電動アシスト付き自転車を使えば、上り坂、向かい坂の辛さは解消する。 雨については、高機能のレインウェアを利用することで、不快さをある程度和らげることができる(傘は禁止)

自転車の利点の一つとして、走行中の空気感、季節感を体全体で感じることができることがあげられる。 木々の緑、花の色、空や雲の色を視覚に捉え、人々の声、鳥や無視の鳴き声を聴覚で聞き、花の香りを嗅覚で感じ、路面の凹凸を触感で感じることができる。 これはバイクでもある程度までなら可能だろうが、自動車では完全に不可能。

  • 運動になり健康によい。
  • 燃料不要で人力だけで走行することができる。排気ガス、エンジン音を出さない。タイヤノイズはとても小さい。
  • 総重量が軽いので生産・リサイクル・破棄の環境負荷が低い。保守で交換が必要となるパーツも小さく、トータルでエコ。
  • 道路上での一台あたり占有面積が狭く、輸送効率が良い。

「世間には自動車という乗り物があるのに、自転車に乗る人の気持ちが理解できない」は残念の極み

自転車に乗れば自転車に乗る人の気持ちが理解できると思うので、まずは自分で法令を守って乗ってみることをおすすめする。 自転車に乗る習慣が無いという方は、まずは以下のような場面で、自転車を選択するといいかも。

  • 有酸素運動を始めたいが、ジョギングは膝や腰が不安。プールはお金がかかる。
  • 徒歩で行くには時間がかかる・体力的につらい距離の移動。
  • 公共交通機関で行くと乗り換えがめんどくさい。バス代を節約したい。
  • 自動車で行くと混雑、道が狭い、駐車場探しがめんどくさい。

「自転車は歩道を走るものだから、歩行者と同じ」は誤り

自転車は車両なので、車道を走るもの。断じて歩行者と同じではない。 歩行者であるにせよ車両であるにせよ、公道を通行するためには法令にしたがう必要がある。 自動車のように、駐めてはいけないところに駐車したり、止まるべきところで止まらなかったり、交通弱者を蹴散らして走行したり、通行してはいけないところを通行するようなことは、あってはならない。

基本的に車道を、左側の端に寄って通行する。(左側の端を走る、というのは誤り)

「ベルを鳴らして、前を歩く歩行者をどかせた」は誤り

道交法で、ベルを鳴らさなければならないと定められているとき以外は、ベルを鳴らしてはいけない。 警笛鳴らせの標識がある場所ではベルを鳴らさなければならない。 また、危険を避ける目的の時はベルを鳴らしてもよいが、前に歩行者がいるなら、自転車が速度を落とせばよいだけなので、「危険を避けるため」には該当しない。 気づいてもらいたい目的なら優しく声かけをすればいい。 「歩行者にとって、邪魔で危ない存在なのは自転車である」という視点は忘れてはいけないl。

自動車にクラクションをならされることがよくあるだろうが、それは自動車による違法行為。自動車が違法行為をしているからといって、違法行為の真似をしてはダメ。

「スピードを出して車道を走ると迷惑だから、歩道を走る」は誤り

急に進路を変えたり、車道右側を走るようなことをせず、法令を守って通行している限り、車道を走って迷惑ということは絶対にない。 自転車に対してすぐ横を追い抜いて行ったり煽ったりクラクションを鳴らしたりするような自動車のほうが、法令を守らない迷惑な存在。 堂々と車道を走るのが正解。

逆に歩道は、自転車通行可の歩道であっても、基本的に歩行者が優先。 自動車の真似をして、すぐ横を追い抜いていったり煽ったりベルを鳴らすようなことは絶対にしてはダメ。

「クッション性を高めるためにタイヤの気圧を下げる」は誤り

空気圧が低いと接地面積が増えて抵抗が増し、進むのに余計な力が必要となる、またパンクの原因となる。 タイヤの空気圧は適正な気圧にする。(指でタイヤを力強く押しても簡単にはへこまないくらい)

「両足が地面にべったりとつかないと危険なので、サドルは極力低くしている」は誤り

地面に両足がべったり付く高さはペダルを回すのに適してない。 ペダルが一番下に来たとき、膝が軽く曲がるくらいにサドルを上げると、快適にペダルを回せる。 停車時にトップチューブにまたがる形で立てば、サドルが高くて地面に足に地面がつかないという問題はなくなる。 歩道を走行すると横から出てくる自動車などに邪魔されるなど咄嗟に止まらざるをえない場面がある。 車道を走れば、信号・一時停止・安全確認等以外では咄嗟に止まらざるをえなくなる場面は少なくなる。

運転していて危険だというのは、サドルの高さや足つきとは別の問題。

「ペダルはたくさんこぐとつかれるから、ゆっくりこげばすむように、一番重いギアにしている」は誤り

ペダルを足で上から下に踏みつけるだけの動きだと考えて動かしていると、効率が悪い。 ペダルは円を描くように動くのだから、回すことを意識する。 また、上り坂も平地でも足の回転数を変えないようにペダルを回すのが疲れにくい効率の良い乗り方。 平地でクルクル回し、上り坂ではギアを軽くして同じようにクルクル回すようにする。

「自転車のメンテは難しそうなので自分でやったことがない」はもったいない。

たしかに難しいところはあるけど、自分でできるところは自分でやると愛着もわくと思う。 空気入れは店頭でもできるけど、空気入れを買って自分でやろう。こまめに空気を補充して快適な走行を。

また、パンク修理、スポーツタイプならさらに、チューブ・タイヤ交換はできるようになっておくと心強い。 パンク修理キットは、100円ショップでも購入することができる。

「自動車社会において、車道を走る自転車は邪魔者である」は誤り

欧州の先進国に止まらず、米国の大都市においても自動車よりも自転車を優先する取り組みが始まっている。 本邦においても、車道を減らす取り組みが報道されている。 自動車に依存していると忘れられがちなのかもしれないが、自動車がいつでもどこでも優先されるというのは都合のよい手前勝手な傲慢な幻想にすぎない。

ansible vault

create a vault file

$ ansible-vault create test
New Vault password: 
Confirm New Vault password: 
:
:
$ ansible-vault view test
Vault password: 
test
$ cat test 
$ANSIBLE_VAULT;1.1;AES256
34373931643530353734633238383738363430616366366463653631316362353730613165316464
3834656662626430306662333038656263613139373036640a303131396539353663383932323133
63316564623264323434326138623737326463633830623465373131646134616662363565656132
3165616239303564330a646436643339303665336333363530346636666339643561336565393434
3766

We can use vault-id option for password instead of stdin.

$ ansible-vault view --vault-id test@prompt test
Vault password (test): 
test
$ cat vaultpass.test 
password

$ ansible-vault view --vault-id test@vaultpass.test test
test

We can also encrypt/decrpt any file

$ ansible-vault decrypt --vault-id test@vaultpass.test test
Decryption successful

$ cat test 
test

$ ansible-vault encrypt --vault-id test@vaultpass.test test
Encryption successful

example for encrypt var file.

$ cat ./roles/test/vars/main.yml 
target: ansible_os_family

$ ansible-vault encrypt --vault-id test@vaultpass.test ./roles/test/vars/main.yml 
Encryption successful

$ cat ./roles/test/vars/main.yml 
$ANSIBLE_VAULT;1.2;AES256;test
33653839336162646466373262663965636561366464643634643431633639343437633166636137
3236636535383832383932353865396630313266366264360a363134333532393038396561323137
30643734663961363561666461326362373035623131663637383636346633393737636234316163
3463663838626334660a616564343730343561656335343534353161666430313731376631623634
65643135323666303430616331666165656131373639393936333731626131653764

ansible-playbook example using encrypted file.

$ cat ./roles/test/tasks/main.yml 
- name: print ansible facts
  debug:
    var: "{{ target }}"

$ cat hosts 
[test]
localhost ansible_connection=local

$ ansible-playbook -i hosts --vault-id test@vaultpass.test --list-tasks test.yml 

playbook: test.yml

  play #1 (test): ansible vault test    TAGS: []
    tasks:
      test : print ansible facts    TAGS: []


$ ansible-playbook -i hosts --vault-id test@vaultpass.test test.yml 

PLAY [ansible vault test] *****************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************
ok: [localhost]

TASK [test : print ansible facts] *********************************************************************************************
ok: [localhost] => {
    "ansible_os_family": "Debian"
}

PLAY RECAP ********************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

squid bump

On debian if you want to analyze or cache the content of the ssl traffic with squid, you have to buid your own squid. This is a sample to build squid using apt source package.

build a docker container

make a dockerfile

FROM debian:buster-slim

WORKDIR /tmp/buildwork
RUN echo 'deb-src http://deb.debian.org/debian buster main' >> /etc/apt/sources.list \
&& apt-get update \
&& apt install --no-install-recommends -y dpkg-dev devscripts build-essential fakeroot libssl-dev libldap2-dev libpam0g-dev libdb-dev cdbs libsasl2-dev debhelper libcppunit-dev libkrb5-dev comerr-dev libcap2-dev libecap3-dev libexpat1-dev libxml2-dev pkg-config libnetfilter-conntrack-dev nettle-dev libgnutls28-dev dh-apparmor ed libdbi-perl libltdl-dev lsb-release libpopt0 logrotate squid-langpack \
&& apt source squid \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*

RUN sed -i.bak -e '/--with-gnutls$/ s/$/ --with-openssl --enable-ssl --enable-ssl-crtd/' squid-4.6/debian/rules \
&& squid-4.6/configure \
&& cd squid-4.6 \
&& debuild -us -uc -b \
&& dpkg -i ../squid_*.deb ../squid-common_*.deb \
&& mkdir -p /var/spool/squid /etc/squid/ssl_cert && chown proxy:proxy /var/spool/squid \
&& cd /tmp && rm -rf /tmp/buildwork

VOLUME ["/var/spool/squid"]
EXPOSE 3128

WORKDIR /var/spool/squid
COPY squid.conf /etc/squid/squid.conf
COPY server.crt /etc/squid/ssl_cert/server.crt
COPY server.key /etc/squid/ssl_cert/server.key

CMD chmod 600 /etc/squid/ssl_cert/server.key \
&& if [ ! -f /var/spool/squid/swap.state ]; then squid -z ; fi \
&& if [ ! -d /var/spool/squid/ssl_db ]; then /usr/lib/squid/security_file_certgen -c -s /var/spool/squid/ssl_db -M 20MB ; chown -R proxy. /var/spool/squid/ssl_db ; fi \
&& squid -N

sample configure file

acl localnet src 192.168.xxx.0/24
acl SSL_ports port 443
acl Safe_ports port 80
acl Safe_ports port 21
acl Safe_ports port 443
acl CONNECT method CONNECT
acl intermediate_fetching transaction_initiator certificate-fetching
http_access allow intermediate_fetching
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
include /etc/squid/conf.d/*
http_access allow localnet
http_access allow localhost
http_access deny all
http_port 3128 ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=4MB cert=/etc/squid/ssl_cert/server.crt key=/etc/squid/ssl_cert/server.key
ssl_bump stare all
sslproxy_cert_error allow all
sslcrtd_children 3 startup=1 idle=1
cache_dir ufs /var/spool/squid 100 16 256
coredump_dir /var/spool/squid
refresh_pattern .               129600  33%     525600
dns_nameservers 192.168.xxx.xxx 192.168.xxx.xxx

If you don't have a CA file and private key for it, you need create them. When you already have them, I think you can use intermediate CA signed by your own CA.

$ openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout server.key -out server.crt -subj "/CN=192.168.xxx.xxx" -days 3650

build an image

$ docker build --build-arg http_proxy=http://192.168.xxx.xxx:3142/ -t squid:test .

run a container

$ sudo docker run --rm squid:test squid --version | awk -F: '$1~/options/{print $2}' | sed -e 's/ /\n/g' | grep ssl
'--with-openssl'
'--enable-ssl'
'--enable-ssl-crtd'
$ docker run --rm -p 3128:3128 -v /mnt/squid:/var/spool/squid -d squid:test

test the address and port

$ curl -D - -s http://192.168.xxx.xxx:3128/ -o /dev/null

connecting to HTTPS server

$ https_proxy=http://192.168.xxx.xxx:3128/ curl -v -k -s https://www.google.com/ -o /dev/null
* Uses proxy env variable https_proxy == 'http://192.168.xxx.xxx:3128/'
*   Trying 192.168.xxx.xxx...
* TCP_NODELAY set
* Connected to 192.168.xxx.xxx (192.168.xxx.xxx) port 3128 (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to www.google.com:443
> CONNECT www.google.com:443 HTTP/1.1
> Host: www.google.com:443
> User-Agent: curl/7.61.1
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 200 Connection established
< 
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
:
:
:
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: C=US; ST=California; L=Mountain View; O=Google LLC; CN=www.google.com
*  start date: May 10 04:04:06 2021 GMT
*  expire date: Aug  2 04:04:05 2021 GMT
*  issuer: CN=192.168.xxx.xxx
*  SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
} [5 bytes data]
> GET / HTTP/1.1
> Host: www.google.com
> User-Agent: curl/7.61.1
> Accept: */*
> 
{ [5 bytes data]
< HTTP/1.1 200 OK
< Date: Wed, 09 Jun 2021 00:22:42 GMT
< Expires: -1
< Cache-Control: private, max-age=0
< Content-Type: text/html; charset=ISO-8859-1
< P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
< Server: gws
< X-XSS-Protection: 0
< X-Frame-Options: SAMEORIGIN
< Set-Cookie: 1P_JAR=2021-06-09-00; expires=Fri, 09-Jul-2021 00:22:42 GMT; path=/; domain=.google.com; Secure
< Set-Cookie: NID=216=ptf-d_HIPGOAjnEf-gbmRDmIg3JnEfjqRRnQghOkyFHrdLy5fXGOhydj5jBHonqOlP5WCzPIKX3kIkdizOXCQ13t4moqXwr-UoOWiRXgYaAkx6gyqe03hjM_hwfin5plUuG3NClONGvvFJo5Mqvar7GFYrSFYOMVCXMXvTJ0d4M; expires=Thu, 09-Dec-2021 00:22:42 GMT; path=/; domain=.google.com; HttpOnly
< Alt-Svc: h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
< Accept-Ranges: none
< Vary: Accept-Encoding
< X-Cache: MISS from bd2e0fa8b95e
< X-Cache-Lookup: MISS from bd2e0fa8b95e:3128
< Transfer-Encoding: chunked
< Via: 1.1 bd2e0fa8b95e (squid/4.6)
< Connection: keep-alive
< 
{ [5 bytes data]
* Connection #0 to host 192.168.xxx.xxx left intact

sample log of other connections

1622798061.167    833 192.168.xxx.xxx NONE/200 0 CONNECT dl.fedoraproject.org:443 - HIER_DIRECT/38.145.60.22 -
1622798061.539    260 192.168.xxx.xxx TCP_MISS/200 16108 GET https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm - HIER_DIRECT/38.145.60.22 application/x-rpm
1622798109.029    496 192.168.xxx.xxx NONE/200 0 CONNECT dl.fedoraproject.org:443 - HIER_DIRECT/38.145.60.22 -
1622798109.130      1 192.168.xxx.xxx TCP_MEM_HIT/200 16115 GET https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm - HIER_NONE/- application/x-rpm

squid nobump

The squid packages of debian doesn not support sslbump. It only redirects ssl traffic. We can not analyze or cache the content of the ssl traffic.

build a docker container

make a dockerfile

FROM debian:buster-slim

RUN apt-get update \
&& apt install -y squid \
s&& apt clean \
&& rm -rf /var/lib/apt/lists/*

VOLUME ["/var/spool/squid"]
EXPOSE 3128

WORKDIR /var/spool/squid
COPY squid.conf /etc/squid/squid.conf

CMD if [ ! -f /var/spool/squid/swap.state ]; then squid -z ; sleep 2; fi \
&& squid -N

sample configure file

acl localnet src 192.168.xxx.0/24
acl SSL_ports port 443
acl Safe_ports port 80
acl Safe_ports port 21
acl Safe_ports port 443
acl CONNECT method CONNECT
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
include /etc/squid/conf.d/*
http_access allow localnet
http_access allow localhost
http_access deny all
http_port 3128
cache_dir ufs /var/spool/squid 100 16 256
coredump_dir /var/spool/squid
refresh_pattern .               129600  33%     525600
dns_nameservers 192.168.xxx.xxx 192.168.xxx.xxx

build an image

$ docker build --build-arg http_proxy=http://192.168.xxx.xxx:3142/ -t squid:test .

run a container

$ docker run --rm squid:test squid --version | awk -F: '$1~/options/{print $2}' | sed -e 's/ /\n/g' | grep ssl
(result will be nothing)
$ docker run --rm -p 3128:3128 -v /mnt/squid:/var/spool/squid -d squid:test

test the address and port

$ curl -D - -s http://192.168.xxx.xxx:3128/ -o /dev/null

connecting to HTTP server

without proxy

$ curl -v -s http://ftp.yz.yamagata-u.ac.jp/pub/linux/centos/5.11/readme -o /dev/null
*   Trying 2001:df0:25e:e100::3...
* TCP_NODELAY set
* Connected to ftp.yz.yamagata-u.ac.jp (2001:df0:25e:e100::3) port 80 (#0)
> GET /pub/linux/centos/5.11/readme HTTP/1.1
> Host: ftp.yz.yamagata-u.ac.jp
> User-Agent: curl/7.64.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 07 Jun 2021 00:59:01 GMT
< Server: Apache/2.4.46 (Unix) OpenSSL/1.1.1k
< Upgrade: h2,h2c
< Connection: Upgrade
< Last-Modified: Mon, 03 Apr 2017 11:34:28 GMT
< ETag: "14b-54c418ac05900"
< Accept-Ranges: bytes
< Content-Length: 331
<
{ [331 bytes data]
* Connection #0 to host ftp.yz.yamagata-u.ac.jp left intact

with proxy

$ http_proxy=http://192.168.xxx.xxx:3128/ curl -v -s http://ftp.yz.yamagata-u.ac.jp/pub/linux/centos/5.11/readme -o /dev/null
* Uses proxy env variable http_proxy == 'http://192.168.xxx.xxx:3128/'
*   Trying 192.168.xxx.xxx...
* TCP_NODELAY set
* Connected to 192.168.xxx.xxx (192.168.xxx.xxx) port 3128 (#0)
> GET http://ftp.yz.yamagata-u.ac.jp/pub/linux/centos/5.11/readme HTTP/1.1
> Host: ftp.yz.yamagata-u.ac.jp
> User-Agent: curl/7.64.0
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 OK
< Date: Mon, 07 Jun 2021 00:58:26 GMT
< Server: Apache/2.4.46 (Unix) OpenSSL/1.1.1k
< Last-Modified: Mon, 03 Apr 2017 11:34:28 GMT
< ETag: "14b-54c418ac05900"
< Accept-Ranges: bytes
< Content-Length: 331
< X-Cache: MISS from e3b21f81fdd2
< X-Cache-Lookup: MISS from e3b21f81fdd2:3128
< Via: 1.1 e3b21f81fdd2 (squid/4.6)
< Connection: keep-alive
<
{ [331 bytes data]
* Connection #0 to host 192.168.xxx.xxx left intact

when cache hit

< Age: 358
< X-Cache: HIT from e3b21f81fdd2
< X-Cache-Lookup: HIT from e3b21f81fdd2:3128

squid log

$ docker exec xxxxxxxxxxxx tail /var/log/squid/access.log
:
1623026732.001    265 192.168.xxx.xxx TCP_MISS/200 685 GET http://ftp.yz.yamagata-u.ac.jp/pub/linux/centos/5.11/readme - HIER_DIRECT/133.24.248.17 -
1623027089.025      0 192.168.xxx.xxx TCP_MEM_HIT/200 693 GET http://ftp.yz.yamagata-u.ac.jp/pub/linux/centos/5.11/readme - HIER_NONE/- -

connecting to HTTPS server

without proxy

$ curl -v -k -s https://www.google.com/ -o /dev/null 
*   Trying 142.250.196.132...
* TCP_NODELAY set
* Connected to www.google.com (142.250.196.132) port 443 (#0)
:

with proxy

$ https_proxy=http://192.168.xxx.xxx:3128/ curl -v -k -s https://www.google.com/ -o /dev/null 
* Uses proxy env variable https_proxy == 'http://192.168.xxx.xxx:3128/'
*   Trying 192.168.xxx.xxx...
* TCP_NODELAY set
* Connected to 192.168.xxx.xxx (192.168.xxx.xxx) port xxxxx (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to www.google.com:443
> CONNECT www.google.com:443 HTTP/1.1
> Host: www.google.com:443
> User-Agent: curl/7.61.1
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 200 Connection established
< 
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
:

squid log. The ssl connection is just tunneled.

$ sudo docker exec xxxxxxxxxxxx tail /var/log/squid/access.log
:
1622950724.481    170 192.168.xxx.xxx TCP_TUNNEL/200 18439 CONNECT www.google.com:443 - HIER_DIRECT/172.217.175.4 -

devpi-server

devpi-server is a server for private package indexes and PyPI caching.

build a docker container

make a dockerfile

FROM debian:buster-slim

ENV DEBIAN_FRONTEND noninteractive
RUN apt update && \
    apt install --no-install-recommends -y \
    python3-pip python3-pip python3-setuptools python3-dev build-essential libffi-dev && \
    pip3 install devpi-server

EXPOSE 3141
VOLUME ["/var/cache/devpi"]

CMD chmod 777 /var/cache/devpi && \
    devpi-server \
        --serverdir /var/cache/devpi \
        --host 0.0.0.0 --port 3141

build an image

$ sudo docker build --build-arg http_proxy=http://192.168.xxx.xxx:3142/ -t devpi-server:buster-slim .
$ sudo docker tag devpi-server:buster-slim devpi-server:latest

run a container

$ sudo docker run --rm -d -p 3141:3141 -v /mnt/devpi:/var/cache/devpi devpi-server:latest

test the address and port

$ curl http://192.168.xxx.xxx:3141/

how to use devpi-server

specify it in a command line

$ pip3 install --trusted-host 192.168.xxx.xxx --index-url http://192.168.xxx.xxx:3141/root/pypi matplotlib

or

$ PIP_TRUSTED_HOST=192.168.xxx.xxx PIP_INDEX_URL=http://192.168.xxx.xxx:3141/root/pypi pip3 install matplotlib

for docker build, write below in a Dockerfile

ARG PIP_TRUSTED_HOST
ARG PIP_INDEX_URL

then specify devpi-server at build-arg parameter in docker run command line.

$ docker build --build-arg PIP_TRUSTED_HOST=192.168.xxx.xxx --build-arg PIP_INDEX_URL=http://192.168.xxx.xxx:3141/root/pypi -t imagename .

ses

aws command

aws ses list-identities

destination.json

{
  "ToAddresses": [
    "test@example.com"
  ],
  "CcAddresses": [],
  "BccAddresses": []
}

message.json

{
  "Subject": {
    "Data": "test mail",
    "Charset": "UTF-8"
  },
  "Body": {
    "Text": {
      "Data": "Hi.\n\nThis is a test mail.",
      "Charset": "UTF-8"
    }
  }
}
aws ses send-email --from noreply@example.net --destination file://destination.json --message file://message.json

template.json

{
  "TemplateName": "testtemplate",
  "SubjectPart": "Greetings, {{name}}!",
  "TextPart": "Dear {{name}},\n\nYour favorite animal is {{favoriteanimal}}."
}
aws ses list-templates
aws ses create-template --template file://template.json
aws ses get-template --template testtemplate

template-parameters.json

{
  "name": "john",
  "favoriteanimal": "cat"
}
aws ses test-render-template --template-name testtemplate --template-data file://template-data.json
aws ses send-templated-email --source noreply@example.net --destination file://destination.json --template testtemplate --template-data file://template-data.json
aws ses delete-template --template-name testtemplate

python test script

#!/bin/usr/python

import boto3
import json

fromaddr = 'noreply@example.net'
destaddr = 'test@example.com'
destination = {
    'ToAddresses': [
        destaddr,
    ]
}

client = boto3.client('ses')

## send email
response = client.send_email(
    Source = fromaddr,
    Destination = destination,
    Message={
        'Subject': {
            'Data': 'test mail',
            'Charset': 'UTF-8'
        },
        'Body': {
            'Text': {
                'Data': 'Hi.\n\nThis is a test mail',
                'Charset': 'UTF-8'
            },
        }
    }
)
print(response)

templates = client.list_templates()
for template in templates['TemplatesMetadata']:
    response = client.get_template(
        TemplateName=template['Name']
    )
    print(response['Template'])

## create template
response = client.create_template(
    Template={
        "TemplateName": "testtemplate",
        "SubjectPart": "Greetings, {{name}}!",
        "TextPart": "Dear {{name}},\n\nYour favorite animal is {{favoriteanimal}}."
    }
)
templatedata = {
    "name": "john",
    "favoriteanimal": "cat"
}

## send templated email
response = client.send_templated_email(
    Source=fromaddr,
    Destination=destination,
    Template='testtemplate',
    TemplateData=json.dumps(templatedata)
)
print(response)

## delete template
response = client.delete_template(
    TemplateName='testtemplate'
)
print(response)

templates = client.list_templates()
for template in templates['TemplatesMetadata']:
    response = client.get_template(
        TemplateName=template['Name']
    )
    print(response['Template'])