nginx 反向代理404(研究了三个小时....哭晕在厕所)

[root@master1 conf.d]# vi /etc/nginx/conf.d/upstream_proxy.conf +21
upstream html {
     
    server worker1:80;
    server worker2:80;
}

server {
     
        listen       8888;
        server_name  html_kevin.com;


        location / {
     
            proxy_pass   http://html;
         }

}
[root@master1 conf.d]# 
[root@master1 conf.d]# 
[root@master1 conf.d]# 
[root@master1 conf.d]# 
[root@master1 conf.d]# nginx -s reload
[root@master1 conf.d]# curl  -i http://html_kevin.com:8888/
HTTP/1.1 200 OK
Server: nginx/1.18.0
Date: Fri, 16 Oct 2020 18:06:16 GMT
Content-Type: text/html
Content-Length: 612
Connection: keep-alive
Last-Modified: Tue, 21 Apr 2020 15:07:31 GMT
ETag: "5e9f0c33-264"
Accept-Ranges: bytes

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
     
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@master1 conf.d]

关键修改: 后端IP换成域名,否则被不代理,只会报404(原因有待研究)


upstream html {
     
    server worker1:80;
    server worker2:80;
}

你可能感兴趣的:(笔记,排错)