2017-09-09 39 views
0

我試圖尋找一個解決這個問題有一段時間了。 但似乎沒有任何工作。Nginx的 - 收到的所有請求去同一個網站

的問題是,每一個請求轉到始終以同一個網站(上ISPconfig配置的第一個網站如果我禁用了第一個,它進入第二個 - 至極現在是第一個)。它甚至不會默認。

調查這個問題,我發現可能nginx的正在接收錯誤的主機的請求(我在我的域名提供商的DNS服務器爲我的子域名CNAME)。

於是我就tcpdump的,但是我發現每個請求實際收到正確:

[email protected]:/etc/nginx/sites-enabled# tcpdump -n -S -s 0 -A 'tcp dst port 80' | grep "Host" 
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode 
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes 
Host: cartoes24.wagnerux.de 
Host: cartoes24.wagnerux.de 
Host: cartoes24.wagnerux.de 
Host: test.wagnerux.de 
Host: test.wagnerux.de 
Host: test.wagnerux.de 

我的虛擬主機confs:

- cartoes24虛擬主機:

server { 
     listen 192.168.1.1:80; 


     server_name cartoes24.wagnerux.de; 

     root /var/www/cartoes24.wagnerux.de/web/; 



     index index.html index.htm index.php index.cgi index.pl index.xhtml; 



     error_page 400 /error/400.html; 
     error_page 401 /error/401.html; 
     error_page 403 /error/403.html; 
     error_page 404 /error/404.html; 
     error_page 405 /error/405.html; 
     error_page 500 /error/500.html; 
     error_page 502 /error/502.html; 
     error_page 503 /error/503.html; 
     recursive_error_pages on; 
     location = /error/400.html { 

      internal; 
     } 
     location = /error/401.html { 

      internal; 
     } 
     location = /error/403.html { 

      internal; 
     } 
     location = /error/404.html { 

      internal; 
     } 
     location = /error/405.html { 

      internal; 
     } 
     location = /error/500.html { 

      internal; 
     } 
     location = /error/502.html { 

      internal; 
     } 
     location = /error/503.html { 

      internal; 
     } 

     error_log /var/log/ispconfig/httpd/cartoes24.wagnerux.de/error.log; 
     access_log /var/log/ispconfig/httpd/cartoes24.wagnerux.de/access.log combined; 

     location ~ /\. { 
         deny all; 
     } 

     location ^~ /.well-known/acme-challenge/ { 
         access_log off; 
         log_not_found off; 
         root /usr/local/ispconfig/interface/acme/; 
         autoindex off; 
         index index.html; 
         try_files $uri $uri/ =404; 
     } 

     location = /favicon.ico { 
      log_not_found off; 
      access_log off; 
     } 

     location = /robots.txt { 
      allow all; 
      log_not_found off; 
      access_log off; 
     } 

     location /stats/ { 

      index index.html index.php; 
      auth_basic "Members Only"; 
      auth_basic_user_file /var/www/clients/client2/web1/web/stats/.htpasswd_stats; 
     } 

     location ^~ /awstats-icon { 
      alias /usr/share/awstats/icon; 
     } 

     location ~ \.php$ { 
      try_files /14d86c825b76b9bcc54ed6b1dbff2e23.htm @php; 
     } 

     location @php { 
      try_files $uri =404; 
      include /etc/nginx/fastcgi_params; 
      fastcgi_pass unix:/var/lib/php5-fpm/web1.sock; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      fastcgi_intercept_errors on; 
     } 

     location /cgi-bin/ { 
      try_files $uri =404; 
      include /etc/nginx/fastcgi_params; 
      root /var/www/clients/client2/web1; 
      gzip off; 
      fastcgi_pass unix:/var/run/fcgiwrap.socket; 
      fastcgi_index index.cgi; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      fastcgi_intercept_errors on; 
     } 
} 

- 測試虛擬主機:

server { 
     listen 192.168.1.1:80; 


     server_name cartoes24.wagnerux.de; 

     root /var/www/cartoes24.wagnerux.de/web/; 



     index index.html index.htm index.php index.cgi index.pl index.xhtml; 



     error_page 400 /error/400.html; 
     error_page 401 /error/401.html; 
     error_page 403 /error/403.html; 
     error_page 404 /error/404.html; 
     error_page 405 /error/405.html; 
     error_page 500 /error/500.html; 
     error_page 502 /error/502.html; 
     error_page 503 /error/503.html; 
     recursive_error_pages on; 
     location = /error/400.html { 

      internal; 
     } 
     location = /error/401.html { 

      internal; 
     } 
     location = /error/403.html { 

      internal; 
     } 
     location = /error/404.html { 

      internal; 
     } 
     location = /error/405.html { 

      internal; 
     } 
     location = /error/500.html { 

      internal; 
     } 
     location = /error/502.html { 

      internal; 
     } 
     location = /error/503.html { 

      internal; 
     } 

     error_log /var/log/ispconfig/httpd/cartoes24.wagnerux.de/error.log; 
     access_log /var/log/ispconfig/httpd/cartoes24.wagnerux.de/access.log combined; 

     location ~ /\. { 
         deny all; 
     } 

     location ^~ /.well-known/acme-challenge/ { 
         access_log off; 
         log_not_found off; 
         root /usr/local/ispconfig/interface/acme/; 
         autoindex off; 
         index index.html; 
         try_files $uri $uri/ =404; 
     } 

     location = /favicon.ico { 
      log_not_found off; 
      access_log off; 
     } 

     location = /robots.txt { 
      allow all; 
      log_not_found off; 
      access_log off; 
     } 

     location /stats/ { 

      index index.html index.php; 
      auth_basic "Members Only"; 
      auth_basic_user_file /var/www/clients/client2/web1/web/stats/.htpasswd_stats; 
     } 

     location ^~ /awstats-icon { 
      alias /usr/share/awstats/icon; 
     } 

     location ~ \.php$ { 
      try_files /14d86c825b76b9bcc54ed6b1dbff2e23.htm @php; 
     } 

     location @php { 
      try_files $uri =404; 
      include /etc/nginx/fastcgi_params; 
      fastcgi_pass unix:/var/lib/php5-fpm/web1.sock; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      fastcgi_intercept_errors on; 
     } 

     location /cgi-bin/ { 
      try_files $uri =404; 
      include /etc/nginx/fastcgi_params; 
      root /var/www/clients/client2/web1; 
      gzip off; 
      fastcgi_pass unix:/var/run/fcgiwrap.socket; 
      fastcgi_index index.cgi; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      fastcgi_intercept_errors on; 
     } 
} 

- 默認虛擬主機: 服務器{ listen 80 default_server;

root /var/www/html; 

    # Add index.php to the list if you are using PHP 
    index index.html index.htm index.nginx-debian.html; 

    server_name _; 
    error_log /home/wagner/default_server_error.log; 
    return 444; 
} 

對不起,如果這個問題已經回答了,但是我發現每個「解決方案」都不適合我。

謝謝!

+0

請運行'nginx -T'並將輸出添加到一個pastebin併發布鏈接到您的問題 –

+0

您好塔倫, 我發現了這個問題。這是與ispconfig(我在我的服務器中使用的東西)的問題。我在虛擬主機配置中有一些錯誤的IP配置。 要修復它,我必須輸入實際的服務器IP而不是*符號,然後才能正常工作。 我應該關閉/刪除這個問題嗎? – user1903554

+0

我認爲你可以提出自己的答案並解釋問題。將來可能會幫助別人犯類似的錯誤 –

回答

0

我找到了解決方案。 我正在使用ISPconfig,並且在WEBSITE選項的Web Domain選項卡的IPv4/IPv6配置中,我必須插入我的服務器的實際本地IP,而不是*。 我不知道它的原因,但它的工作原理是這樣的。

相關問題