igmdvc edited a comment on issue #1660: Override webp lossless decision logic
URL: 
https://github.com/apache/incubator-pagespeed-ngx/issues/1660#issuecomment-517697969
 
 
   > I am thinking about possible workarounds. Would it be possible to override 
the Vary: User-Agent header that pagespeed is adding into response with Vary: 
Accept within the NGINX configuration?
   
   Just answering myself and probably others 
https://github.com/apache/incubator-pagespeed-ngx/issues/1107 and 
https://github.com/apache/incubator-pagespeed-ngx/issues/1149.
   
   Instead of trying to force a specific order of different modules, the idea 
is to create a self proxy based on server block
   ```
   server {
       server_name pagespeed.local; 
       listen 80;
   
       access_log off; 
   
       allow 127.0.0.1;
       deny all;
   
       # Pagespeed configuration
       pagespeed on;
       ...
   }
   ```
   
   Then you can proxy the files you want to be processed by pagespeed
   ```
   proxy_pass http://127.0.0.1:80;
   proxy_pass_request_headers on;
   proxy_set_header Host pagespeed.local;
   ```
   
   Finally you can rely on map blocks to process the response returned by the 
self proxy and use $upstream_http_<headername> variables. For example, in my 
particular case:
   ```
   map $upstream_http_Vary $custom_vary {
       default '';
       '~*User-Agent' 'Accept';
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to