解决nginx 反向代理跳转带上端口的问题

server {
    listen     127.0.0.1:80;
    server_name demo.test.cn;

    try_files $uri $uri/ /index.html;

    location / {
           proxy_pass http://192.168.1.130:8080/;
           server_name_in_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_hide_header  X-Powered-By;
           }
    location /wechat_sroa {
           proxy_pass http://192.168.1.130:8080/wechat_sroa/;
           server_name_in_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_hide_header  X-Powered-By;
           }

        location /api/ {
           proxy_pass http://192.168.1.130:8399/api/;
           server_name_in_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_hide_header  X-Powered-By;
           proxy_buffering off;
          proxy_buffer_size 128k;
          proxy_buffers   32 32k;
          proxy_connect_timeout 300s;
          proxy_send_timeout 300s;
          proxy_read_timeout 300s;
        }

        location /App {
           include uwsgi_params;
           proxy_pass http://192.168.1.130:8080/App;
        }

       location /welcome {
           include uwsgi_params;
           proxy_pass http://192.168.1.130:8080/welcome;
        }
       
       location /personal {
           include uwsgi_params;
           proxy_pass http://192.168.1.130:8080/personal;
        }

       location /transport {
           include uwsgi_params;
           proxy_pass http://192.168.1.130:8080/transport;
        }

       location /sso {
           include uwsgi_params;
           proxy_pass http://192.168.1.130:8080/sso;
        }

       location /srm {
           include uwsgi_params;
           proxy_pass http://192.168.1.130:8080/srm;
        }

       location /oms {
           include uwsgi_params;
           proxy_pass http://192.168.1.130:8080/oms;
        }

       location /fms {
           include uwsgi_params;
           proxy_pass http://192.168.1.130:8080/fms;
        }

       location /crm {
           include uwsgi_params;
           proxy_pass http://192.168.1.130:8080/crm;
        }

       location /ccs {
           include uwsgi_params;
           proxy_pass http://192.168.1.130:8080/ccs;
        }

       location /bsm {
           include uwsgi_params;
           proxy_pass http://192.168.1.130:8080/bsm;
        }
       location /exchange {
           include uwsgi_params;
           proxy_pass http://192.168.1.130:8080/exchange;
        }


}
######
server {
    listen     127.0.0.1:80;
    server_name z.test.cn;

       location / {
           proxy_pass http://192.168.1.130:8301/;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_hide_header  X-Powered-By;
           proxy_buffering off;
           proxy_buffer_size 128k;
           proxy_buffers    32 32k;
        }
}
######
server {
    listen    127.0.0.1:80;
    server_name demo.file.test.cn;
    client_max_body_size 20m;
    error_log  /usr/local/nginx/logs/demo_file_error.log;

    try_files $uri $uri/ /index.html;
        location / {
           add_header 'Access-Control-Allow-Origin' '*' always;
           add_header 'Access-Control-Allow-Credentials' 'true' always;
           add_header 'Access-Control-Allow-Methods' '*'  always;
           add_header 'Access-Control-Allow-Headers' '*'  always;
           proxy_pass http://192.168.1.130:8321/;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_hide_header  X-Powered-By;
           proxy_buffering off;
           proxy_buffer_size 128k;
           proxy_buffers   32 32k;
        }
}
server {
    listen    127.0.0.1:443 ssl;
    server_name demo.file.test.cn;
    client_max_body_size 20m;
    error_log  /usr/local/nginx/logs/demo_file_error.log;

    ssl_certificate /usr/local/nginx/ssl/5235531_demo.file.test.cn.pem;
    ssl_certificate_key /usr/local/nginx/ssl/5235531_demo.file.test.cn.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    try_files $uri $uri/ /index.html;
        location / {
           add_header 'Access-Control-Allow-Origin' '*' always;
           add_header 'Access-Control-Allow-Credentials' 'true' always;
           add_header 'Access-Control-Allow-Methods' '*'  always;
           add_header 'Access-Control-Allow-Headers' '*'  always;
           proxy_pass http://192.168.1.130:8321/;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_hide_header  X-Powered-By;
           proxy_buffering off;
           proxy_buffer_size 128k;
           proxy_buffers   32 32k;
        }
}

######
server {
    listen     127.0.0.1:80;
    server_name demo.wechat.test.cn;

        location / {
           proxy_pass http://192.168.1.130:8320/;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_hide_header  X-Powered-By;
           proxy_buffer_size 128k;
           proxy_buffers   32 32k;
        }

        location /driver {
           proxy_pass http://192.168.1.130:8330/;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_hide_header  X-Powered-By;
           proxy_buffer_size 128k;
           proxy_buffers   32 32k;
        }



}
######
server {
    listen     127.0.0.1:80;
    server_name demo.driver.test.cn;

        location / {
           proxy_pass http://192.168.1.130:8330/;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_hide_header  X-Powered-By;
           proxy_buffer_size 128k;
           proxy_buffers   32 32k;
        }
}
######
server {
    listen     127.0.0.1:80;
    server_name demo.barge.test.cn;

        location / {
           proxy_pass http://192.168.1.130:8315/;
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_hide_header  X-Powered-By;
           proxy_buffering off;
           proxy_buffer_size 128k;
           proxy_buffers   32 32k;
        }
}

  

posted @ 2021-03-30 15:59  佚小名  阅读(2498)  评论(1编辑  收藏  举报