etag missing when doing a proxy_pass

ayma nginx-forum at forum.nginx.org
Fri Apr 26 21:23:51 UTC 2019


Hi

I'm trying to use ETags with nginx when looking at html data (Content-Type:
text/html).  I don't see an issue when the content-type comes back as
Content-Type: text/plain.  


To reduce noise I tried the following:

I created an nginx conf file on my local host that would serve up an html
page and created the ETag header inside 

server {

    listen 3000;

          location / {
                etag off;
              proxy_http_version 1.1;
              root  /var/www/nginx/default;
              more_set_headers    "testEtag: adfaa-dfsdfasdf";
              more_set_headers    "ETag: adfaa-dfsdfasdf";
          }

  }


I tried with etag on and the resulting curl did not generate an ETag header
so I tried with etag off.


Next to simulate the proxy_pass scenario I created another nginx conf file
with the following:


  server {


    listen 5000;


        location  /echoheaders {

             etag off;

                #more_set_headers ETag:$upstream_http_etag;
                more_set_headers x-my-e-tag:$upstream_http_etag;
                more_set_headers "my-test-etag:adfasdfadfadsf";
                more_set_headers "ETag:234adfl-affai9f";


                        proxy_pass http://127.0.0.1:3000/;
        }

  }

Then I did the following curl cmds:

root at public-crd0edf9d103b74bc088058b9011bc6f59-alb1-6d5979ccf5-jn5qs:/etc/nginx/conf.d#
curl -I http://127.0.0.1:3000/                
HTTP/1.1 200 OK
Date: Fri, 26 Apr 2019 21:18:29 GMT
Content-Type: text/html
Connection: keep-alive
testEtag: adfaa-dfsdfasdf
ETag: adfaa-dfsdfasdf
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Cache-Control: no-cache

Which shows an ETag header


curl -I http://127.0.0.1:5000/echoheaders
HTTP/1.1 200 OK
Date: Fri, 26 Apr 2019 21:18:21 GMT
Content-Type: text/html
Connection: keep-alive
testEtag: adfaa-dfsdfasdf
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Cache-Control: no-cache
x-my-e-tag: adfaa-dfsdfasdf
my-test-etag: adfasdfadfadsf

Goes through a proxy pass and does not show a ETag header.  removing the
etag directive or setting it to etag on; in the config files with the proxy
pass does not seem to have any affect.

Wondering if there is some known behavior with ETag and proxy_pass?  Also
wondering what nginx is doing so that I can't just set the ETag header
manually.  It seems like nginx is the one removing the header?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,283945,283945#msg-283945



More information about the nginx mailing list