다중 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;
    }

관련 정보