Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running an EC2 instance with Ubuntu and trying to setup virtual servers for two domains without luck and cannot figure out why. My web documents are located in /var/www/<domain> and everything under the www folder belongs to www-data:www-data (currently it's only two index.htmls for the two domains). I've put the site config files in /etc/nginx/sites-available and linked them in sites-enabled. Site config files and symlinks also belong to www-data:www-data just in case. I've also added my domains with the public ip of the server to /etc/hosts and port 80 is of course enabled in EC2 console.

Here is the /etc/nginx/nginx.conf:

user www-data www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
    worker_connections  16;
}

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log debug;

    gzip on;
    gzip_disable "msie6";

    include /etc/nginx/sites-enabled/*;
}

And one of the site configs (the other one differs by the domain only):

server {
    listen      80;
    server_name domain1.com www.domain1.com;

    root        /var/www/domain1;
    index       index.html;

    access_log  /var/log/nginx/access_domain1.log;
    error_log   /var/log/nginx/error_domain1.log;
}

The server is of course restarted after every change in the configuration. Adding a location directive like:

location / {
    index index.html;
    root /var/www/domain1;
}

also doesn't help. Adding try_files (eg. $uri $uri/) also doesn't help. Defining a default server in nginx.conf, like:

server {
    listen 80 default_server;
    server_name localhost;
    root /var/www;
    index index.html;
}

also won't help.

Server is nginx 1.1.19.

Despite the configuration I only get "Welcome to nginx!" on both domains instead of the index.html files placed in /var/www.

share|improve this question
    
Might be better addressed in SuperUser SE. –  mdpc Dec 20 '12 at 17:16
    
I don't see anything immediately wrong in your configuration. If it's not looking where you put the root, where is it looking at? additionally, please verify your included directory. –  Grumpy Dec 21 '12 at 4:56
    
"Adding a location directive also didn't help" ... where did you add the location directive .. means which section ? –  GeekRide Dec 22 '12 at 2:43
    
Are you sure that incoming requests are actually handled by nginx that you are configuring? F.e. are they logged to access.log? –  sendmoreinfo Dec 27 '12 at 20:15
    
finally i could solve the configuration problem. i'm not sure what exactly helped, but i did two things: 1) created and associated an "elastic IP" with the server instance using the AWS console (please note that the requests were always handled by the server (hence the "Welcome to nginx!" landing page)) 2) created a default configuration for the localhost, which I've deleted earlier (the file called "default" in the Ubuntu package) to minimize the number of configuration files. so one of these or both have helped, not sure. –  kiri__ Dec 29 '12 at 14:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.