nginx 报错 HTTP Status 400 – Bad Request

  • 今天使用nginx对nacos集群进行负载均衡报错:页面报错 HTTP Status 400 – Bad Request

  • 查看日志

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;
        }

     }

}

网上找了半天没找到如何解决

突然把proxy_pass http://nacos_cluster;,改为proxy_pass http://nacoscluster;, upstream里一样,然后就成功了…

是因为配置访问路径时,不能出现特殊字符…

猜你喜欢

转载自blog.csdn.net/woschengxuyuan/article/details/130549132