多个 Server_name

多个 Server_name

我有一个内部 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;
    }

相关内容