例如有如下两个location配置
[code="java"]
location ~ /xxx/.+$ {
proxy_pass http://tomcat;
proxy_set_header Host $host;
proxy_set_header X-URI $request_uri;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ /yyy/.+$ {
rewrite ^/yyy/(.+)$ /ddd?x=$1 break;
proxy_pass http://tomcat;
proxy_set_header Host $host;
proxy_set_header X-URI $request_uri;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
[/code]
两个location中有很多重复配置项,这些配置项有什么办法只配置一次就能在所有location中引用?