簡體   English   中英

Nginx重寫和proxy_pass解釋

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM