Is there a Nginx configuration to block IE10 DNT?

Carson Reinke asked:

Apache has a patch to block the Do Not Track header for Internet Explorer 10. What Nginx configuration change can I use to do the same?

My answer:


When nginx is a reverse proxy to upstream backend servers, use proxy_set_header, something like this:

proxy_set_header DNT ""

When sending to FastCGI/FPM, such as in the case of PHP, use fastcgi_hide_header, for example:

fastcgi_hide_header DNT

Keep in mind you’ll have to wrap this in an if to test for IE 10, and If is evil, so this configuration will probably come back to bite you. If you only have one if in the location block, you’ll probably be OK…

if ($http_user_agent ~ Trident/6.0) {
    proxy_set_header DNT ""
}

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.