1

Please see EDIT2 on the bottom for updated question

I am trying to setup a web application with Node.JS hosted via DigitalOcean on an Ubuntu droplet (not sure if relevant). The support tutorials call for setting up an nginx server to serve the app to the domain. I got to the part where it asks to restart nginx, but it failed on my droplet. I then found this question that answers how to tests the nginx config and return a more verbose error, which was:

user@droplet:/etc/nginx/sites-enabled$ sudo nginx -c /etc/nginx/nginx.conf -t
nginx: [warn] conflicting server name "[my domain.ext here]" on 0.0.0.0:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] bind() to [droplet ip here]:8080 failed (99: Cannot assign requested address)
nginx: configuration file /etc/nginx/nginx.conf test failed

I tried messing around some more and found this question that offers a slightly different way to setup an nginx server, but I still get the same error. I'm really not sure what the problem is anymore and was looking for some guidance on where I can find the solution.

Thank you

EDIT: My nginx.conf file is below. I haven't changed anything in it:


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

    events {
        worker_connections 768;
        # multi_accept on;
    }

    http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

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

        ##
        # Logging Settings
        ##

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

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##

        #include /etc/nginx/naxsi_core.rules;

        ##
        # nginx-passenger config
        ##
        # Uncomment it if you installed nginx-passenger
        ##

        #passenger_root /usr;
        #passenger_ruby /usr/bin/ruby;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
    }


    #mail {
    #   # See sample authentication script at:
    #   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
    # 
    #   # auth_http localhost/auth.php;
    #   # pop3_capabilities "TOP" "USER";
    #   # imap_capabilities "IMAP4rev1" "UIDPLUS";
    # 
    #   server {
    #       listen     localhost:110;
    #       protocol   pop3;
    #       proxy      on;
    #   }
    # 
    #   server {
    #       listen     localhost:143;
    #       protocol   imap;
    #       proxy      on;
    #   }
    #}

EDIT2: Below is /etc/nginx/sites-enabled/default. I got it such that if you go type the public ip address into your browser address bar, it serves the index file correctly. But if you go to the [domain.ext], theres just the "server not found" error the browser throws. I assume its something simple with the configuration now, but I am still lost.

/etc/nginx/sites-enabled/default

# works if you go to the ip address, but not the domain
server {
    listen 80;

    server_name [domain.ext];
    root /home/yazan/;

    location / {
        proxy_pass http://[droplet public ip address]:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}
Community
  • 1
  • 1
YazanLpizra
  • 520
  • 1
  • 11
  • 32
  • 1
    It sounds like your config file is not setup correctly (eg, it seems to be trying run your site on "[my domain.ext here]"). You can output the contents of your config file by entering this command: `cat /etc/nginx/nginx.conf` - then post it here. – duncanhall Jan 21 '16 at 17:31
  • Done, I didn't edit anything in it because the tutorials don't mention changing anything in it – YazanLpizra Jan 21 '16 at 17:40
  • 2
    That is only part of your configuration. The interesting bits are in `/etc/nginx/conf.d/*.conf` and/or `/etc/nginx/sites-enabled/*`. – Richard Smith Jan 22 '16 at 11:29
  • I have nothing in the conf.d directory, but I posted the file from sites-enabled. – YazanLpizra Jan 22 '16 at 12:23

0 Answers0