Setting up the rewriting rules for the request proved to be quite easy in Nginx. For the response, not so much (at least, not for me). I want to strip the Content-Type header from the response if the Content-Length header of the response isn't set. I have the NginxHttpHeadersMoreModule installed, so that should allow me to remove the header, but I can't seem to find a way to check for the existence of the Content-Length header of the response using a rule in Nginx's configuration. Any suggestions on how to do this would be most appreciated!
Nginx – How to check for the existence of a response header in Nginx rules
httphttp-headersnginx
Related Topic
- Nginx Reverse Proxy – How to Rewrite Domain Part of Set-Cookie
- Nginx – Remove Content-Length header in nginx proxy_pass
- Nginx – Content Length and Transfer Encoding Chunked nginx, node-http-proxy
- Windows – IIS7 Response header exposes server information when post request is incomplete
- Nginx gzip_static removes Content-Encoding header
- Nginx – Why does NGinx send content in a HTTP 304 response when If-None-Match / If-Modified-Since is a match
- Nginx on CentOS: How to change the “Server” header
Best Answer
Looks like someone asked this on Stack Overflow, and there is a variable for each sent header called $sent_http_my_custom_header.
See https://web.archive.org/web/20140606142058/http://wiki.nginx.org/HttpCoreModule#.24sent_http_HEADER for the details.
Reference: https://stackoverflow.com/questions/12431496/nginx-read-custom-header-from-upstream-server