nginx配置部分

 server {
        listen       85;
        server_name  localhost;
        client_max_body_size 100M;

      	 # 声光报警器
          location ^~ /gpcloud/ {
                 proxy_set_header Host $host:$server_port;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_next_upstream http_502 http_504 error timeout invalid_header;
                 proxy_pass http://localhost:8306/;
          } 
          
           location ^~ /v2.0/ {
                 proxy_set_header Host $host:$server_port;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_next_upstream http_502 http_504 error timeout invalid_header;
                 proxy_pass http://localhost:8306/;

          } 
           location ^~ /open/  {
               proxy_set_header Host $host:$server_port;
                 proxy_set_header X-Real-IP $remote_addr;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_next_upstream http_502 http_504 error timeout invalid_header;
                 proxy_pass http://localhost:8306/open/;
            }

          location ^~ /v1.0/ {
                 proxy_set_header Host $host:$server_port;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_next_upstream http_502 http_504 error timeout invalid_header;
                 proxy_pass http://www.ruhrtec.cn:8080/;
          } 
            
    location ^~ /webstatic/ {
                 proxy_set_header Host $host:$server_port;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_next_upstream http_502 http_504 error timeout invalid_header;
                proxy_pass http://localhost:8306/webstatic/;
          }

            location ^~ /user/  {
                 proxy_set_header Host $host:$server_port;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_next_upstream http_502 http_504 error timeout invalid_header;
                 proxy_pass http://localhost:8306/user/;
            }
            location ^~ /u/  {
                 proxy_set_header Host $host:$server_port;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_next_upstream http_502 http_504 error timeout invalid_header;
                 proxy_pass http://localhost:8306/u/;
            }

            location ^~ /share/  {
                 proxy_set_header Host $host:$server_port;
                 proxy_set_header X-Real-IP $remote_addr;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_next_upstream http_502 http_504 error timeout invalid_header;
                 proxy_pass http://localhost:8306/share/;
            }
            location ^~ /ws/  {
                proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade"; 
        proxy_set_header Host $host:$server_port;
                 proxy_set_header X-Real-IP $remote_addr;
                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                 proxy_next_upstream http_502 http_504 error timeout invalid_header;
                 proxy_pass http://localhost:8085/ws/;
            }



 		  root /data/wzy/dist;

          index index.html;

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

        location / {
        		try_files $uri $uri/ @router;
             index index.html;
         }
         location @router {
            rewrite ^.*$ /index.html last;
         }

这是一份本地的nginx配置文件,其中location ^~ /open/ 这一块表示对这个开头的URL进行处理,会将其转到 http://localhost:8306/open/这个接口上,就比如http://192.168.1.153:85/open/chart/show这个接口,会自动转换成http://192.168.1.153:8306/open/chart/show这个接口,如果其为http://localhost:8306/ 那就会转换成http://localhost:8306/chart/show。

        listen       85; //映射的端口
        server_name  localhost;//映射的URL

这块表示将端口映射成什么样子。以及映射的URL,

会自动将http://localhost:85/user/doLogin       转换成      http://localhost:8306/user/doLogin  

猜你喜欢

转载自blog.csdn.net/queryById/article/details/82912025