Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an nginx server acting as a load balancer for my apache servers. I am using subdomains and my code relies on the HTTP_HOST value to perform the correct task.

When i make a request to say: once it is forwarded the HTTP_HOST on apache becomes

My question is how do I make it stay the same as the original request?

Here is my nginx config:

upstream {
  server weight=2;
  server weight=1;
  server weight=1;

server {
  listen 80;
  location / {

I tried adding multiple proxy_pass, one for each subdomain and it doesn't seem to work.

share|improve this question
up vote 4 down vote accepted

You need to pass along the HTTP Host header. Add this to the relevant location:

proxy_set_header Host $host;
share|improve this answer
wow thank you, this worked like a charm. – Ibu May 9 '13 at 19:18

Your Answer


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.