Tuesday, August 09, 2022

Apache 的 name-based virtual host

在 Apache 上面 name-based virtual host 是指: 利用 Host: 這個 HTTP Header (標頭) 決定要用哪個網站組態設定來回應來自瀏覽器的請求。

從 Name-based Virtual Host Support 這篇文章看起來,現在 Apache 建議無論如何就設定 <VirtualHost> 就對了。

搜尋 request 要用哪個 <VirtualHost> 處理時,會先看 request 所連線的目標 IP:Port 組合,先把有 match 到的部份最精確 (exact match) 的設定挑出來,當有多個設定相符時,會進去看 ServerName 來比對。

用 Host header 比對 ServerName 時,雖然 Host header 可以攜帶 Port,但是比對時會被忽略,只會使用瀏覽器連線時的目標 Port 進行比對。

Monday, May 16, 2022

Podman 清除建置失敗的殘餘容器資料

使用 podman build 建置容器時,建置失敗的中間容器會被留下來,而且不會被 podman system prune -a 清除。

$ podman system prune -a
WARNING! This command removes:
	- all stopped containers
	- all networks not used by at least one container
	- all images without at least one container associated with them
	- all build cache

Are you sure you want to continue? [y/N] y
Error: Image used by fbcfbb...7e8: image is in use by a container

這個原因看起來是因為 podman system prune 清除的對象是 Podman 本身產生的資料,而 podman build 背後是透過 Buildah 來進行建置,而這部份就不被認為是 Podman 的直接行為。細節可以參考在 #7889 Failed to remove image, image is in use by container 這個 Issue 裡的描述。

處理的方式就是手動刪除,先執行 podman ps --all --storage 把所有的容器列出來,再用 podman rm 刪掉。

$ podman ps --all --storage
CONTAINER ID  IMAGE                                      COMMAND     CREATED      STATUS      PORTS       NAMES
b396d84310a4  docker.io/library/ubuntu:16.04             buildah     10 days ago  storage                 ubuntu-working-container
fbcfbbc3c233  docker.io/library/bd7139...bed-tmp:latest  buildah     10 days ago  storage                 793b78...79a-working-container
$ podman rm b396d84310a4 fbcfbbc3c233