nginx reports HTTP Status 400 – Bad Request

  • Today, nginx is used to load balance the nacos cluster and report an error: page error HTTP Status 400 – Bad Request

  • view log

192.168.198.1 - - [07/May/2023:22:12:21 +0800] "GET /nacos HTTP/1.1" 400 435 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
  • nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

   
    upstream nacoscluster{
        server 192.168.198.129:8849;
        server 192.168.198.129:8859;
        server 192.168.198.129:8869;
     }

     server {
         listen       8001;
         server_name  localhost;

         location /nacos {
         proxy_pass http://nacoscluster;
         }
     }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html{
            root   html;
        }

     }

}

I searched online for a long time and couldn't find how to solve it

Suddenly proxy_pass http://nacos_cluster;changed, to proxy_pass http://nacoscluster;, the same as in upstream, and then it succeeded...

It is because special characters cannot appear when configuring the access path...

Guess you like

Origin blog.csdn.net/woschengxuyuan/article/details/130549132