[英]Why nginx always redirects to one of my virtual hosts?
I have several virtual hosts configured with nginx. 我有几个用nginx配置的虚拟主机。 They are very simiral to each other and for most of them, everything seems to be working fine.
它们彼此非常相似,并且对于大多数它们来说,一切似乎都正常。
However, 然而,
Most of the virtual hosts look like this: 大多数虚拟主机如下所示:
server {
server_name iibs.co;
return 302 $scheme://www.iibs.co$request_uri;
}
server {
server_name www.iibs.co;
root /var/www/iibs.co;
index index.php;
include global/restrictions.conf;
client_max_body_size 64M;
# Additional rules go here.
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass php;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
# Only include one of the files below.
# include global/wordpress.conf;
# include global/wordpress-ms-subdir.conf;
# include global/wordpress-ms-subdomain.conf;
}
I just tried adding another one, very similar just with different domain and root. 我只是尝试添加另一个,非常相似,只是具有不同的域和根。 And that particular one, also getting redirected to the same first vhost on the list.
那个特定的,也被重定向到列表中的第一个虚拟主机。
At this point, I have no idea where and what should I looks for. 在这一点上,我不知道我应该在哪里寻找什么。
This is an example of default NGINX config for prevent redirects to the first of the existing virtual hosts . 这是默认NGINX配置的示例,用于防止重定向到现有的第一个虚拟主机。
### Block all illegal host headers. Taken from a discussion on nginx
### forums. Cf. http://forum.nginx.org/read.php?2,3482,3518 following
### a suggestion by Maxim Dounin. Also suggested in
### http://nginx.org/en/docs/http/request_processing.html#how_to_prevent_undefined_server_names.
server {
listen 80 default_server; # IPv4
#listen [::]:80 default_server ipv6only=on; # IPv6
server_name _;
server_name "";
return 444;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.