Question

Multiple sites on different domains using nginx

Posted July 1, 2013 26.7k views
different server_name parameters for different server doesn't work.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
5 answers
You may need to post up the configs for any help.
We have an article on setting up virtual hosts for multiple domains with nginx: https://www.digitalocean.com/community/articles/how-to-set-up-nginx-virtual-hosts-server-blocks-on-ubuntu-12-04-lts--3
I have to nginx configs:
/etc/nginx/sites-enabled/sub1.mydomain.com:
server {
listen 80;
server_name sub1.mydomain.com;
location / {
proxy_pass http://localhost:8080;
}
}

/etc/nginx/sites-enabled/sub2.mydomain.com:
server {
listen 80;
server_name sub2.mydomain.com;
location / {
proxy_pass http://localhost:8081;
}
}

I made two a records in dns:
sub1 IN A
sub2 IN A

Have i done everything correctly?
I made two a records in dns:
sub1 IN A x.x.x.x
sub2 IN A x.x.x.x
Solved. In http section i added:
server_names_hash_bucket_size 64;
Thanks for all!
Submit an Answer