2017-08-28 162 views
1

我有一個node.js應用程序運行在我的Ubuntu 14.04 VPS上。 通過Cloudfare從dns到pm2運行應用程序,一切都設置完成。Nginx:[警告]衝突服務器名稱「non.com」在0.0.0.0:80,忽略

我遇到了與Nginx配置文件衝突的問題。 我對這一切都很陌生,所以我不知道它是如何工作的100%。

做一些谷歌搜索顯示我通過使用納米編輯器可能有.save文件,使它衝突,我檢查,情況並非如此。雖然,我確實在/nginx/sites-available//nginx/sites-enabled/內有相同的文件。

這裏被稱爲default文件:我重啓nginx的我得到一個警告nginx: [warn] conflicting server name "domainName.com" on 0.0.0.0:80, ignored

server { 
    listen 80; 

    server_name domainName.com; 

    location/{ 
     proxy_pass http://MY-IP:3000/; 
     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; 
    } 
} 

每次。

這裏是我的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; 

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

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

    gzip on; 
    gzip_disable "msie6"; 

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

ls -al /etc/nginx/sites-enabled輸出:

輸出 ls -alh /etc/nginx/conf.d/
total 8 
drwxr-xr-x 2 root root 4096 Aug 28 07:33 . 
drwxr-xr-x 5 root root 4096 Aug 28 07:33 .. 
lrwxrwxrwx 1 root root 34 Aug 28 07:33 default -> /etc/nginx/sites-available/default 

total 8.0K 
drwxr-xr-x 2 root root 4.0K Jul 12 06:35 . 
drwxr-xr-x 5 root root 4.0K Aug 28 07:33 .. 

我不知道還能做什麼,任何幫助,將不勝感激。

+0

發佈你的nginx.conf和'ls -al/etc/nginx/sites-enabled' –

+0

@TarunLalwani我添加了你所問的內容,它在帖子的末尾。 –

+0

還需要'ls -alh/etc/nginx/conf.d /'和其中的任何配置的內容 –

回答

0

要解決我的問題,我在/etc/nginx/sites-available/default上將proxy_pass http://MY-IP:3000/;更改爲proxy_pass http://localhost:3000/;

然後我停止了Apache2使用sudo service apache2 stop,重新啓動nginx與sudo service nginx restart和所有工作完全正常。

顯然我使用我的VPS的IP而不是使用本地主機作爲地址。