Caddy 反向代理 Portainer(Caddy reverse proxy container)

想必看到这篇文章的人不是出现了 就是出现了
如果按照官网给的下面这句代码来反向代理端口,完全没办法成功,我没搞懂这个8000端口是干嘛的,但是明显没P用,9443 端口 Portainer 又自己套了 SSL 证书也没办法直接反向代理

Not Found
send http request to https
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:2.11.1

解决办法:

先查找到 Portainer 容器的所在IP

docker inspect --format '{{ .NetworkSettings.IPAddress }}' <container-ID>

然后直接反向代理 9000 端口

# 这里的<container-ID>是你上一步查询到的容器IP
#
your.domain {
  reverse_proxy <container-ID>:9000
}

PS. 以后直接映射 9000 端口就行了,我现在懒得改了

docker run -d -p 9000:9000 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:2.11.1
# 我没有使用 docker 安装 caddy,而是直接安装在本机
# 
your.domin {
  reverse_proxy 127.0.0.1:9000
}
————————

The person who wants to see this article either appears or appears
If you reverse proxy the port according to the following code given on the official website, you can’t succeed at all. I don’t understand what this 8000 port is for, but it’s obviously useless. Port 9443 has its own SSL certificate, and there’s no way to reverse proxy directly

Not Found
send http request to https
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:2.11.1

terms of settlement:

Find the IP address of the container first

docker inspect --format '{{ .NetworkSettings.IPAddress }}' <container-ID>

Then directly reverse proxy 9000 ports

# 这里的<container-ID>是你上一步查询到的容器IP
#
your.domain {
  reverse_proxy <container-ID>:9000
}

PS. in the future, just map the 9000 port directly. I’m too lazy to change it now

docker run -d -p 9000:9000 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:2.11.1
# 我没有使用 docker 安装 caddy,而是直接安装在本机
# 
your.domin {
  reverse_proxy 127.0.0.1:9000
}