
我有一個內部 php 應用程序,基本上每天下午都會凍結用戶。我曾經重新啟動應用程式(docker),這可以緩解一天的問題,但不能永遠解決它。所以今天我深入研究了nginx錯誤日誌。更仔細地查看錯誤讓我意識到請求已發送到 172.17.8.101。這個IP是我在本地用於開發的本地IP,但當我推送到生產時,IP是192.168.254.96。所以我想我可以在伺服器區塊中放置兩個不同的 ip,但我一定是錯的。
2015/03/03 15:44:44 [error] 42#0: *7006 open() "/var/www/contentlibrary/favicon.ico" failed (2: No such file or directory), client: 192.168.254.63, server: 172.17.8.101, request: "GET /favicon.ico HTTP/1.1", host: "192.168.254.96:8083"
2015/03/03 15:44:44 [error] 42#0: *7006 open() "/var/www/contentlibrary/favicon.ico" failed (2: No such file or directory), client: 192.168.254.63, server: 172.17.8.101, request: "GET /favicon.ico HTTP/1.1", host: "192.168.254.96:8083"
2015/03/03 14:11:17 [error] 40#0: *6715 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.254.80, server: 172.17.8.101, request: "POST /pagecreator/index.php/page_creator/grouping/getGroupsByContentId HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-fpm.sock", host: "192.168.254.96:8083", referrer: "http://192.168.254.96:8083/app/index.php?user=John%20Doe"
2015/03/03 14:22:15 [error] 40#0: *6726 open() "/var/www/contentlibrary/favicon.ico" failed (2: No such file or directory), client: 192.168.254.63, server: 172.17.8.101, request: "GET /favicon.ico HTTP/1.1", host: "192.168.254.96:8083"
conf 檔案中的伺服器區塊使用多個伺服器名稱。由於這會中斷生產,因此在不創建兩個不同的伺服器區塊的情況下如何支援我的開發環境?
include /etc/nginx/conf.d/*.conf;
index index.php index.html index.htm;
## Content Library
server {
server_name 172.17.8.101 192.168.254.96; // Problem HERE
#access_log logs/contentlibrary_access.log;
root /var/www/contentlibrary;
#default_type text/html;
index index.php index.html index.htm;
location / {
}
location /app{
try_files $uri $uri/ /index.php /index.php$uri =404;
root /var/www/contentlibrary/app;
}
location ~* \.(jpg|jpeg|gif|png|html|htm|css|zip|tgz|gz|rar|doc|xls|pdf|ppt|tar|wav|bmp|rtf|swf|flv|txt|xml|docx|xlsx|js)$ {
try_files $uri $uri/ /index.php$uri =404;
access_log off;
expires 30d;
}