【发布时间】:2017-09-09 14:41:12
【问题描述】:
一段时间以来,我一直试图寻找解决此问题的方法。 但似乎没有任何效果。
问题是每个请求总是发送到同一个网站(在 ISPconfig 上配置的第一个网站。如果我禁用第一个,它会转到第二个 - 现在是第一个)。它甚至不会默认。
调查这个问题,我发现可能是 nginx 在请求中接收到错误的主机(我的域提供商 dns 服务器中的子域有一个 cname)。
于是我跑了tcpdump,但我发现实际上每个请求都被正确接收了:
root@server:/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
我的虚拟主机配置:
--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;
}
}
-- 默认虚拟主机: 服务器 { 监听 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;
}
如果这个问题已经得到解答,我很抱歉,但我发现的每个“解决方案”都对我不起作用。
谢谢!
【问题讨论】:
-
请运行
nginx -T并将输出添加到 pastebin 并将链接发布到您的问题中 -
你好,Tarun,我发现了问题。这是 ispconfig 的一个问题(我在我的服务器中使用的东西)。我在虚拟主机配置中有一些错误的 IP 配置。要修复它,我必须输入实际的服务器 IP 而不是 * 符号,然后它才能工作。我应该关闭/删除这个问题吗?
-
我认为您可以提出自己的答案并解释问题。可能会帮助将来犯类似错误的人
标签: nginx webserver vhosts ispconfig