• nginx 地址匹配规则


    一、location 后面的url地址最后加/,和不加/的区别

    location /jspm-center-mgr/api/jsis/tojscp/ {
              proxy_pass   http://10.10.203.127:8766/api/jsis/;
              proxy_connect_timeout 300s;
              proxy_send_timeout 300s;
              proxy_read_timeout 300s;
    }

    此处:/jspm-center-mgr/api/jsis/tojscp/ 这个是全路径去匹配此匹配的全部删掉后,

    重新用http://10.10.203.127:8766/api/jsis/   这个地址去拼接后面的地址去请求

    还有nginx是从上到下来匹配的,精确匹配要写在模糊匹配之后,才不会出错

    二、地址最后后面没有/,则不会被截取,直接在http://10.1.22.86:8090'拼接,如果需要改地址,则在重写里面改

    '/jpark-center-mgr/pm-base': {
        target: 'http://10.1.22.86:8090',//正谦本地
        changeOrigin: true,
        pathRewrite: {
          '^/jpark-center-mgr/pm-base': '/jspm-center-mgr/pm-base'
        }
      },

     三、先在浏览器上输入地址看能不能通,然后再在nginx代理,注意,这是顺序

    #user root;
    worker_processes  9;
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        client_max_body_size 10m;
        include       mime.types;
        default_type  application/octet-stream;
    
        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer" '
        #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
        #access_log  logs/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
    
        #gzip  on;
        
        upstream api-gateway {
            #server 10.1.21.136:8766;
            #server 10.10.203.127:8765;
            server 10.10.203.127:8766;
            
        }
        upstream api-door {
            server 10.10.203.126:8765;
        }
        upstream api-dev{
          server 10.101.90.121:8765;
        }
        upstream alarm-ws {
                server 10.10.203.127:8968;
        }
        server {
            listen       8089;
           # server_name  t.jslife.net;
            server_name  10.10.203.127;
        #ssl on;
        #    listen       443 ssl;
        #ssl_certificate      cert.pem;
        #ssl_certificate_key  cert.key;
        #ssl_session_cache    shared:SSL:1m;
        #ssl_session_timeout  5m;
        #ssl_ciphers  HIGH:!aNULL:!MD5;
        #ssl_prefer_server_ciphers  on;
    
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            #jpark-center-mgr
            location ~ ^/(jpark-center-mgr)/.*.(html|js|map|css|gif|jpg|png|woff|woff2|ttf|eot|svg|json)$ {
              add_header Content-Security-Policy 'frame-ancestors self http://t.jslife.net';
              root   html;
            }
            location ~ ^/(jspo-sc-mgr)/.*.(html|js|map|css|gif|jpg|png|woff|woff2|ttf|eot|svg|json)$ {
              root   html;
            }
            location ~ ^/(door-control)/.*.(html|js|map|css|gif|jpg|png|woff|woff2|ttf|eot|svg|json)$ {
              root   html;
            }
        #    location ~ ^/(jspm-center-mgr)/.*.(html|js|map|css|gif|jpg|png|woff|woff2|ttf|eot|svg|json)$ {
            #  root   html;
           # }
            
            #/api/jsis
            #/api/admin
            #/api/tools
            #/api/auth
            #/api/jsrmbiz
            #
            location /jpark-center-mgr/api {
                proxy_pass   http://api-gateway/api;
                proxy_connect_timeout 18000;
                proxy_send_timeout    18000; 
                proxy_read_timeout    18000;
            }
                    location test/jpark-center-mgr/api {
                            proxy_pass   http://10.10.206.81:8765/api;
                            proxy_connect_timeout 18000;
                            proxy_send_timeout    18000;
                            proxy_read_timeout    18000;
            }
            location /v2.3 {
                proxy_pass   http://api-gateway;
                proxy_connect_timeout 18000;
                proxy_send_timeout    18000; 
                proxy_read_timeout    18000;
            }
            
            location /jsis-door{
                            proxy_pass   http://api-door/api;
                            proxy_connect_timeout 18000;
                            proxy_send_timeout    18000; 
                            proxy_read_timeout    18000;
            }
    
            location /jpark-center-mgr/dev/api{
                proxy_pass  http://api-dev/api;
                proxy_connect_timeout 18000;
                proxy_send_timeout    18000; 
                proxy_read_timeout    18000;
           }
    
            location / {
                add_header Cache_Control "no-cache, no store";
                root   html;
                index  index.html index.htm;
                  try_files  $uri $uri/ /index.html;
            }
            
            location /jspo-sc-mgr/base {
               proxy_pass   http://10.10.203.127:8730/base;
               proxy_connect_timeout 300s;
               proxy_send_timeout 300s;
               proxy_read_timeout 300s;
            }
    
            location /jspo-sc-mgr/data {
               proxy_pass   http://10.10.203.127:8730/data;
               proxy_connect_timeout 300s;
               proxy_send_timeout 300s;
               proxy_read_timeout 300s;
            }
    
            
            # 车位管家1.2新增 ---调车场服务
            location /jspm-center-mgr/api/jsis/tojscp-parkService/ {
              proxy_pass   http://10.10.203.127:8766/api/jsis/;
              proxy_connect_timeout 300s;
              proxy_send_timeout 300s;
              proxy_read_timeout 300s;
            }
            
            # location /jspm-center-mgr/api/jsis/tojscp-parkService/ {
            #   proxy_pass http://10.10.203.127:8767/;
            # }
            
            
            # 车位管家1.2新增 ---调车场服务
            location /jspm-center-mgr/api/jsis/tojscp/ {
              proxy_pass   http://10.10.203.127:8766/api/jsis/;
              proxy_connect_timeout 300s;
              proxy_send_timeout 300s;
              proxy_read_timeout 300s;
            }
            
           
           #车位管家 --唐红亮新增 2020-09-21
            location /jspm-center-mgr/pm-base {
                   proxy_pass   http://10.10.205.148:8765/pm-base;
                   proxy_connect_timeout 300s;
                   proxy_send_timeout 300s;
                   proxy_read_timeout 300s;
            }
            
           #车位管家--查询台 --唐红亮新增 2020-09-22
            location /jseq-center-mgr/pm-base {
                   proxy_pass   http://10.10.205.148:8765/pm-base;
                   proxy_connect_timeout 300s;
                   proxy_send_timeout 300s;
                   proxy_read_timeout 300s;
            }        
            
           #车位管家微信 --唐红亮新增 2020-09-21
            location /wx {
                   proxy_pass   http://wx.indoorun.com;
                   proxy_connect_timeout 300s;
                   proxy_send_timeout 300s;
                   proxy_read_timeout 300s;
            }
            
    
            location /jpark-center-mgr/ws {
                proxy_pass   http://alarm-ws/jsiscp-warnservice;
                proxy_connect_timeout 300s;
                proxy_send_timeout 300s;
                proxy_read_timeout 300s;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
            }
    
            #error_page  404              /404.html;
    
            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
            
    
            location /pic {
                root /home/jht/;
                autoindex on;
            }
    
            # proxy the PHP scripts to Apache listening on 127.0.0.1:80
            #
            #location ~ .php$ {
            #    proxy_pass   http://127.0.0.1;
            #}
    
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            #
            #location ~ .php$ {
            #    root           html;
            #    fastcgi_pass   127.0.0.1:9000;
            #    fastcgi_index  index.php;
            #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            #    include        fastcgi_params;
            #}
    
            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            #location ~ /.ht {
           #    deny  all;
            #}
        }
    
    
        # another virtual host using mix of IP-, name-, and port-based configuration
        #
        #server {
        #    listen       8000;
        #    listen       somename:8080;
        #    server_name  somename  alias  another.alias;
    
        #    location / {
        #        root   html;
        #        index  index.html index.htm;
        #    }
        #}
    
    
        # HTTPS server
        #
        #server {
        #    listen       443 ssl;
        #    server_name  localhost;
    
        #    ssl_certificate      cert.pem;
        #    ssl_certificate_key  cert.key;
    
        #    ssl_session_cache    shared:SSL:1m;
        #    ssl_session_timeout  5m;
    
        #    ssl_ciphers  HIGH:!aNULL:!MD5;
        #    ssl_prefer_server_ciphers  on;
    
        #    location / {
        #        root   html;
        #        index  index.html index.htm;
        #    }
        #}
    
    }
    location /jspm-center-mgr/api/jsis/tojscp/ {
              proxy_pass   http://10.10.203.127:8766/api/jsis/;
              proxy_connect_timeout 300s;
              proxy_send_timeout 300s;
              proxy_read_timeout 300s;
            }
  • 相关阅读:
    弦图点染色问题
    BZOJ1098: [POI2007]办公楼biu
    BZOJ1097: [POI2007]旅游景点atr
    BZOJ1068: [SCOI2007]压缩
    BZOJ1055: [HAOI2008]玩具取名
    BZOJ4199: [Noi2015]品酒大会
    BZOJ2527: [Poi2011]Meteors
    BZOJ1493 [NOI2007]项链工厂
    BZOJ1095 ZJOI2007 Hide 捉迷藏
    bzoj1468 Tree
  • 原文地址:https://www.cnblogs.com/mmzuo-798/p/15104803.html
Copyright © 2020-2023  润新知