2013-06-23 53 views
1

我在Nginx 1.4.1上有以下nginx 2虛擬主機,它不起作用。當我註釋掉第一臺虛擬主機時,它工作正常。下面給我一個503錯誤。nginx重寫規則失敗 - 導致503錯誤

任何想法我應該嘗試嗎?

server { 
    listen *:80; 
    server_name website.co; 
    rewrite ^(.*) http://www.website.co$1 permanent; 
} 

server { 
    listen *:80; 
    server_name www.website.co; 
    index index.php; 
    root /var/www/html/website.co; 
    location ~ \.php$ { 
    try_files $uri = 404; 
    fastcgi_pass unix:/tmp/website.co.sock; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include fastcgi_params; 
    fastcgi_intercept_errors on; 
    } 

}

三江源

+0

這個'/ tmp/website.co.sock'是你的襪子文件的路徑嗎? –

+0

也請向我們提供錯誤日誌文件'/ var/log/nginx/error.log'中的錯誤行 –

回答

2

這是不是一個真正的答案,但對於您的重定向塊重寫(直到你提供有關錯誤日誌的詳細信息)

還請確認php sock文件實際上位於/tmp/website.co.sock

更改此

server { 
    listen *:80; 
    server_name website.co; 
    rewrite ^(.*) http://www.website.co$1 permanent; 
} 

這個

server { 
    listen 80; 
    server_name website.co; 
    return 301 $scheme://www.website.co$request_uri; 
} 

這是比較有效,因爲它不需要重寫引擎。