Using proxy_ignore_headers in NGINX

nginx proxy ignore headers
26 July 2025

Understanding proxy_ignore_headers in NGINX


If we want to talk a bit about NGINX, we should say that this web server is one of the best options for web servers and reverse proxying. This web server can receive requests from clients and send responses back to other servers. In this context, we have options called proxy_ignore_headers that can be particularly useful in certain situations.


Imagine a scenario where a server that you are proxying to may send responses that could potentially cause issues in dealing with clients. For example, it might be that the server adds Cache-Control to the responses, causing the client to cache it. This action is usually not desired, and for this reason, we can use proxy_ignore_headers to prevent this header from being involved.


By using this option, we can specify which headers should not be taken into account in responses. This is useful for times when you want more control over the response headers and want to customize them to meet specific needs; it can be very practical.


In the following, we will examine a practical example of configuring proxy_ignore_headers and provide necessary explanations alongside it.


Code examples and explanations


location /api {
proxy_pass http://backend_server;
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Expires;
}

Code explanations


location /api
This line specifies that the configurations inside this block will be applied to requests that are routed to the address /api.


proxy_pass http://backend_server;
This line specifies that responses to the requests should be sent to the backend_server.


proxy_ignore_headers Cache-Control;
This line instructs NGINX to ignore the Cache-Control header in responses that come from the proxied server.


proxy_ignore_headers Expires;
This line similarly instructs NGINX to ignore the Expires header, which is generally used for expiration times of cached content.


FAQ

?

How can I ignore specific headers in NGINX?

?

Will ignoring specific headers affect my website's performance?

?

When should I use proxy_ignore_headers?