[英]Nginx rewrite and proxy_pass explanation
我可以在 nginx/okd 配置中看到以下位置:
location /STFlow/ {
rewrite ^/STFlow(.*)$ $1 last;
#
# Are four lines below executed if rewrite has last option ???
# What's the point of them?
#
proxy_pass http://zuul-proxy:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $http_x_forwarded_for;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
}
location / {
add_header debug-header dbg5;
set $realip $remote_addr;
if ($http_x_forwarded_for ~ "^(\d+\.\d+\.\d+\.\d+)") {
set $realip $1;
}
proxy_pass http://zuul-proxy:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $http_x_forwarded_for;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
client_max_body_size 50M;
}
在location /STFlow/
下面有四行rewrite ^/STFlow(.*)$ $1 last;
曾经被处决过吗?
如果是什么时候?
他们有什么意义?
如果该重写规则有一个break
标志而不是last
,它会在将/STFlow/some/path
/STFlow
前缀中删除它,即除了location
debug-header
和$realip
变量。 但据我了解,使用last
标志会使四行永远不会执行,进一步的 URI 处理将在第二个location
块内完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.