2015-08-18 26 views
0

我用下面的鏈接上的說明:設置Uberjar與Nginx的數字海洋VPS

"Hosting Clojure Web Apps in 7 Easy Steps"

我知道uberjar的作品,因爲我測試了我的兩個開發計算機和VPS上。

這只是Nginx似乎無法找到它。 我懷疑它是與本網站代碼:

# Web sockets 
location /chsk { 
proxy_pass http://backend/chsk; 
proxy_http_version 1.1; 
proxy_set_header Upgrade $http_upgrade; 
proxy_set_header Connection "upgrade"; 
} 

...但我不知道如何糾正它...感謝您的幫助!其他

一兩件事:在站點文件中的「上游後端」我都嘗試127.0.0.1:3000和0.0.0.0:3000,但沒有成功。

這裏是默認的站點配置:

server { 
# Replace this port with the right one for your requirements 
listen [::]:80 ipv6only=off; 

# Multiple hostnames separated by spaces. Replace these as well. 
server_name clmitchell.net www.clmitchell.net main.clmitchell.net 
books.clmitchell.net dna.clmitchell.net help.clmitchell.net 
history.clmitchell.net svcs.clmitchell.net; 
server_name_in_redirect off; 

root /data/nginx/www/$host; 

error_page 401 /error/401.shtml; 
error_page 402 /error/402.shtml; 
error_page 403 /error/403.shtml; 
error_page 404 /error/404.shtml; 
error_page 500 501 502 503 504 /error/500.shtml; 

location ^~ /error/ { 
    internal; 
    root /data/nginx/www/www.clmitchell.net; 
} 


access_log /var/log/nginx/$host-access.log; 
error_log /var/log/nginx/error.log; 

index index.php index.html index.htm default.html default.htm; 
# Support Clean (aka Search Engine Friendly) URLs 
location/{ 
     try_files $uri $uri/ /index.php?$args; 
} 

# serve static files directly 
location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ { 
    access_log off; 
    expires max; 
} 

location ~ \.php$ { 
    try_files $uri =404; 
    fastcgi_split_path_info ^(.+\.php)(/.+)$; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_index index.php; 
    include fastcgi_params; 
} 

location ~ \.scm$ { 
    include fastcgi_params; 
    fastcgi_intercept_errors on; 
    # By all means use a different server for the fcgi processes if you need to 
    fastcgi_pass 127.0.0.1:9981; 
} 

    location ~ /\.ht { 
    deny all; 
    } 
} 

我刪除history.clmitchell.net從服務器名稱列表。

下面是當前歷史站點配置:

upstream backend { 
    server 104.131.29.212:3000 fail_timeout=0; 
} 

server{ 
    listen [::]:80 ipv6only=off; 
    server_name localhost history.clmitchell.net; 

    access_log /var/log/hist_access.log; 
    error_log /var/log/hist_error.log; 

    root /var//resources/public; 

    # Web sockets 
    location /chsk { 
    proxy_pass http://backend/chsk; 
    proxy_http_version 1.1; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
    } 

    # Static assets 
    location/{ 
    try_files $uri @backend; 
    } 

    # The backend server 
    location @backend { 
    proxy_pass http://backend; 
    proxy_set_header Host $http_host; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto $scheme; 
    proxy_redirect off; 
    } 
} 

存在重複的「聽」的歷史現場的配置,我刪除......但出於某種原因,我仍然得到錯誤指令: 「

sudo nginx -t nginx: [emerg] duplicate listen options for [::]:80 in /etc/nginx/sites-enabled/hist:6 nginx: configuration file /etc/nginx/nginx.conf test failed

+0

指向您配置背後的教程的鏈接已死亡。請修復。 –

+0

不,它不是......我只是在它上面並測試了我的問題中的鏈接。 – Quasaur

+0

然後我想知道'http://%22Hosting%20Cllojure%20Web%20Apps%20in%207%20Easy%20Steps%22'應該是什麼意思。 –

回答

1

請嘗試

proxy_pass http://backend; 

並確保您可以訪問http://127.0.0.1:3000/chsk,如果你的上游定義如下

upstream backend { 
    server 127.0.0.1:3000; 
} 

或者,如果我們只有一個後端服務器,我們可以只使用proxy_pass沒有定義的上游後端。例如

proxy_pass http://127.0.0.1:3000; 
+0

感謝您的反饋意見;我已經添加了更多的細節...請審查和建議。 – Quasaur

+0

請給我看你的/etc/nginx/nginx.conf。我認爲它有重複的聽選項。 – xfeep

+0

你說得對,我已經糾正了......謝謝! – Quasaur

0

今天我學到了一個新課:Nginx網絡服務器上沒有兩個站點可以有相同的監聽端口! 我將新網站移到新的端口並更新了所有鏈接...問題已解決!

+1

這不是真的!這個例子是OK的:'服務器{listen_8082; server_name domainA; } server { listen 8082; server_name domainB; '但是如果我們有相同的server_name和相同的端口,它將會失敗。 – xfeep