0

i have a load balancer with nginx and pass traffic to other servers. everything is working fine but i am allowing my clients to add their own custom domain name or use a subdomain from my domain and i can't get the domain name from the servers handling the requests. is there a way i can pass the domain name from the load balancer to the servers. now in the sever i just get the name of the upstream

upstream backend {
        server xxx.xxx.xxx.xxx;
}

server {
    location / {
        proxy_pass http://backend;
    }
}

interested of the domain name i get backend.

thank you

2
  • server name is missing in the configuration. how should nginx know, what content should be served?
    – djdomi
    Aug 5 at 21:45
  • i didn't post the whole config i posted only the part that has anything to do with the question. thanks for your comment Aug 5 at 22:31

1 Answer 1

0

For HTTP upstream, you can simply use proxy_set_header, as below

upstream backend {
        server xxx.xxx.xxx.xxx;
}

server {
    location / {
        proxy_pass        http://backend;
        proxy_set_header  Host "the domain name you wanted";
    }
}
1
  • Thanks this is exactly what i am looking for . Aug 6 at 0:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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