图集1/1

正文 895字数 516,371阅读


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; } }
Run code
Cut to clipboard


    用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"
    Run code
    Cut to clipboard