-1

I'm new to server stuff and started learning nginx, so any help is greatly appreciated.

I have 3 domains from cpanel with the same IP address namely extra1.example.com, backend1.example.com and backend2.example.com

this is my nginx config

upstream backends {
   server backend1.example.com:443;
   server backend2.example.com:443;
}

server {
  server_name main.example.com;
  
  location / {
       proxy_pass https://backends;
       proxy_http_version 1.1;
       proxy_set_header Host $host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection '';
       proxy_cache_bypass $http_upgrade;

       // SSL settings here
  }
  
}

And I run nginx -t and it's fine. Now the problem is whenever browse the site https://main.example.com it displays the content of extra1.example.com. Is there something wrong I've done here? I've googling everything but I can't find the answer. Please help. Thank you

P.S. the loading balancer domain is from different hosting provider.

3

1 Answer 1

0

It looks like you have attempted to anonymize your config but either forgot what aliases you were using when composing this post or did not apply the config after changing it.

All you need is is to have different server blocks for each host name.

1
  • sorry, I have updated it now.. each host is in different server blocks it’s hosted in cpanel using apache Nov 26 at 8:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .