server {
listen 80;
# Allow file uploads
client_max_body_size 50M;
location ^~ /static/ {
root /var/www;
if ($query_string) {
expires max;
}
}
location = /favicon.ico {
rewrite (.*) /static/favicon.ico;
}
location = /robots.txt {
rewrite (.*) /static/robots.txt;
}
location /wechat8000 {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://frontends;
}
}
nginx监听80端口 ,匹配url为localhost+/wechat8000的路由
匹配后转到http://frontends,按顺序访问多个端口,有返回值就停止
访问程序端口的时候url还是+/wechat8000后缀 在程序中进行匹配