在Ubuntu上为节点应用程序发送nginx错误:(99:无法分配请求的地址)

时间:2016-01-21 17:13:23

标签: node.js ubuntu nginx

请参阅底部的EDIT2以获取更新的问题

我正在尝试使用通过DigitalOcean在Ubuntu Droplet上托管的Node.JS设置一个Web应用程序(不确定是否相关)。 support tutorials调用设置nginx服务器以向域提供应用程序。我到了要求重新启动nginx的部分,但它在我的Droplet上失败了。然后我发现this question回答了如何测试nginx配置并返回更详细的错误,即:

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

我尝试了更多的东西,并发现this question提供了一种稍微不同的方式来设置nginx服务器,但我仍然得到相同的错误。我真的不确定问题是什么,并且正在寻找一些关于我能找到解决方案的指导。

谢谢

编辑:我的nginx.conf文件如下。我没有改变任何内容:


    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:下面是/ etc / nginx / sites-enabled / default。我得到它,如果您在浏览器地址栏中输入公共IP地址,它会正确地提供索引文件。但是如果你去[domain.ext],浏览器会抛出“服务器未找到”错误。我现在假设配置简单,但我仍然输了。

  

的/ etc / nginx的/ /默认启用位点-

# 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;
    }
}

0 个答案:

没有答案