我可以在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;
是否已执行?
如果是,什么时候?
他们有什么意义?
答案 0 :(得分:1)
如果该重写规则具有break
标志而不是last
,它将在将其传递给上游之前从/STFlow
URI中删除/STFlow/some/path
前缀。 e。除了设置location
和debug-header
变量外,其他操作与第二个$realip
块相同。但是据我所知,使用last
标志使从未执行过四行,第二个location
块内部将进行进一步的URI处理。