2015-04-16 59 views
2

最後修改標頭我有問題的Nginx充當代理serwer: 請求 - > NGINX PROXY - >應用服務器(只有一個)Nginx的代理 - 返回來自上游

代理服務器監聽端口443和一個應用程序服務器位於80.上游服務器返回的標頭正在被代理刪除。我被迫使用:

add_header 'Content-Length' $upstream_http_content_length;

它工作正常進行的Content-Length,但它不與Last-Modified頭工作。 Nginx代理使用專用IP向上遊發送curl請求將返回所有標頭。爲什麼Nginx代理會將此標題剪掉,即使它的返回是使用add_header指定的?

我有以下nginx.conf樣本:

location /some-web-app { 
        proxy_pass http://backend/some-web-app; 
        proxy_redirect off; 
        proxy_redirect http $scheme; 
        proxy_set_header Host $host; 
        add_header 'Last-Modified' $upstream_http_last_modified; 
        add_header 'Content-Length' $upstream_http_content_length; 
        sub_filter 'codebase="http' 'codebase="https'; 
        sub_filter_types application/x-java-jnlp-file; 
        access_log /var/log/nginx/some-web-app_access.log combined_jsession_upstream; 
        error_log /var/log/nginx/some-web-app_err.log; 
        auth_basic   "Restricted"; 
        auth_basic_user_file /etc/nginx/htpasswd; 
      } 
+0

同樣的問題,男人,任何膠水呢?.. –

回答

0

向前返回Last-Modified頭放下面的位置塊指令:

sub_filter_last_modified on 

要轉發任何其他標題使用add_header$upstream_http_${header}。在這裏,我將轉發內容長度標題:

add_header 'Content-Length' $upstream_http_content_length;