将容器/etc/nginx/conf.d/default.conf复制到宿主主机中
docker cp 容器id:/etc/nginx/conf.d/nginx.conf /home
编辑该文件为如下内容:
upstream local_tomcat{
server 172.17.0.3:8080;
server 172.17.0.4:8080;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://local_tomcat;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
再将该文件复制回原来的容器中,替换源文件:
docker cp /home/default.conf d24b775334da:/etc/nginx/conf.d/
最后从其docker的nginx容器
docker restart 容器id
网友评论