server {
listen 80;
server_name 1.com;
location / {
#root /usr/share/nginx/html;
#index index.html index.htm index.php;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header Host $http_host;
#proxy_pass http://127.0.0.1:801;
proxy_pass http://172.20.0.1:801;
#proxy_pass http://172.20.0.1;
}
}用nginx docker 做反向代理出现502 Bad Gateway
nginx在docker中,不能使用127.0.0.1:801来访问宿主机里的应用,
docker内部实际上实现了一个虚拟网桥docker0,
所以要通过宿主机内网地址(172.20.0.1)来访问
2021/07/19 06:49:36 [error] 7#7: *1 open() "/home/wwwroot/favicon.ico" failed (2: No such file or directory), client: 172.20.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:801", referrer: "http://127.0.0.1:801/1.php"
Docker教程:使用Docker容器运行Nginx并实现反向代理
Docker 部署Nginx 并且挂载默认请求路径和配置文件
Docker 安装 Nginx 并个性化挂载配置文件 nginx.conf
宝塔 thinkPHP5 nginx 站点配置 伪静态
tp3.2 nginx 伪静态