dimuls
By:
dimuls

Multiple sites on different domains using nginx

July 1, 2013 17.2k views
different server_name parameters for different server doesn't work.
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
by Etel Sverdlov
This tutorial shows you how to set up a new directory, how to grant the correct permissions, how to add content to a new page, how to turn on virtual hosting, and how to, if needed, set up local hosts. Virtual Hosts are used to run more than one website or domain off of a single server and IP address. When used with nginx, virtual hosts are called Server Blocks. This tutorial covers setting up server blocks on an Ubuntu server.
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!
Have another answer? Share your knowledge.