配置如下
server { listen 80; server_name xxxxxxxx; access_log /var/log/nginx/inetrnal_access.log main; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_connect_timeout 60; proxy_read_timeout 60; proxy_set_header X-Forwarded-For $http_x_forwarded_for; #proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404; add_header X-Cache "$upstream_cache_status from $server_addr"; client_max_body_size 20m; location ~* ^/([A-Za-z0-9\-.]*) { proxy_pass http://fujie_$1; } allow 10.0.0.0/8; deny all; } upstream fujie_ues-ws { sticky; server xxxxxxxx:8160 max_fails=3 fail_timeout=2; server xxxxxxxx:8160 max_fails=3 fail_timeout=2; } upstream fujie_mns-web { sticky; server xxxxxxxx:8156 max_fails=3 fail_timeout=2; server xxxxxxxx:8156 max_fails=3 fail_timeout=2; } upstream fujie_ufs { sticky; server xxxxxxxx:8090 max_fails=3 fail_timeout=2; server xxxxxxxx:8090 max_fails=3 fail_timeout=2; }
location 那段的意思是,忽略大小写,路径匹配所有大小写字符和数字,以及横岗 后的任意一个字符,匹配任意数量
而方向代理的$1变量是location的路径的第一个参数,也就是正则匹配到的字符串
原文地址:http://blog.51cto.com/wks97/2085573
时间: 2024-10-03 13:09:14