1

I have web server with apache2 with many subdomains on it like, domain.com, abc.domain.com, def.domain.com etc. etc. Now I got a new nginx server and want to set it up like apache2, so to test I created configs (2 files in /etc/nginx/sites-available/ and link to them from sites-enabled/) as shown,

domain.config:

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /srv/www/;
        index index.html index.htm;

        # Make site accessible from http://localhost/
        server_name domain.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
}

abc-domain config:

server {
        listen 80;
        listen [::]:80;

        root /srv/www/tmp1/;
        index index.html index.htm;

        # Make site accessible from http://localhost/
        server_name abc.domain.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
}

but when I access with domain.com I am getting index.html from /var/www/tmp1 only. Is there something I'm doing wrong in the nginx config?

Your Answer

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

Browse other questions tagged or ask your own question.