公司开发环境不问题,每次开发总要重新配置下反向,总要麻烦后台大佬,后来自己试着配了几次也就那么回去,记录下来
第一步 监听本地端口
listen 80;
server_name 127.0.0.1;
第二步 配置接口代理
location /ws-microservice-backstage {
proxy_pass http://192.168.0.105:8303;
client_max_body_size 100m;
client_body_buffer_size 2048k;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_connect_timeout 3;
proxy_send_timeout 30;
proxy_read_timeout 60;
}
第三步,页面代理
location / {
proxy_pass http://127.0.0.1:8091;
client_max_body_size 100m;
client_body_buffer_size 2048k;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_connect_timeout 3;
proxy_send_timeout 30;
proxy_read_timeout 60;
}
}
就3个步骤,很简单