Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do I get NGINX to pass through the 'server' header of upstream servers?

Like, if NGINX is proxying to an Apache server with the Server header 'Apache2.2 (CentOS)', it strips it out and replaces it with 'NGINX/1.0.1'. We have our machine ID's in our Server: headers so we need to get NGINX to stop over-writing them.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Nginx does not have a way to turn off the server header, the closest option is the server token directive but this only turns off the version number.

I have never actually tried this, but the proxy_pass_header directive might allow you to specify the Server header as something that should be passed on to the client.

I'd personally recommend sending the machine ID in a custom header designed for it (X-WHATEVER) as using a RFC defined header for behaviour other than what it's designed for is bound to bite you eventually.

If proxy_pass_header doesn't work then I'm pretty sure the only alternative is that you patch the Nginx source to not overwrite it.

share|improve this answer
    
I didn't write the software (Personally I think it's a stupid idea but anyway. I'll have a play around with the proxy_pass_header and if all else fails start messing around in the source code =) –  sam Jun 12 '11 at 10:06

Any headers from the original response might be preserved using the $upstream_http_* variables, for your case:

add_header Server $upstream_http_server;

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.