nginx多站点配置,无法通过域名访问,使用ip访问会跳转到其中一个站点
在一台服务器设置了Nginx多站点,但是访问这些站点的域名均无法访问,错误如下图:
通过ip会跳转到其中一个站点,具体表现为:
全部配置开启的情况下所有域名无法访问,ip访问显示的是siteD
去除siteD后跳转siteB,去除siteB后404,去除siteB后跳转siteA,去除siteA后跳转siteC
检查了半天还是不知道是啥问题,请各位大神帮忙排查下/w\
以下为具体配置文件:
nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
server_tokens off;
underscores_in_headers off;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
default.conf
server {
listen 80;
server_name _;
location / {
return 404;
}
}
siteA.conf
server {
listen 80;
server_name siteA.domain.com;
access_log /var/log/nginx/siteA.access.log main;
location / {
root /usr/share/nginx/html/siteA;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
#try_files $uri =404;
#root /usr/share/nginx/html/siteA;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/dev/shm/php5.6-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
}
siteB.conf
server {
listen 80;
server_name siteB.domain.com;
access_log /var/log/nginx/siteB.access.log main;
location / {
root /usr/share/nginx/html/siteB;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
root /usr/share/nginx/html/siteB;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/dev/shm/php5.6-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
}
siteC.conf
server {
listen 80;
server_name siteC.domain.com;
access_log /var/log/nginx/siteC.access.log main;
location / {
root /usr/share/nginx/html/siteC/;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
root /usr/share/nginx/html/siteC/;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/dev/shm/php5.6-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
}
siteD.conf
server {
listen 80;
server_name siteD.domain.com;
access_log /var/log/nginx/siteD.access.log main;
location ~ ^/(baidu|webscan|yx_scan) {
root /usr/share/nginx/siteD;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Accept-Encoding "";
proxy_redirect off;
proxy_pass http://127.0.0.1:8080/siteD/;
rewrite ^/WebGoat/(.*)$ /$1 last;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Nginx Info (使用apt安装,mainline)
nginx version: nginx/1.11.9
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
built with OpenSSL 1.0.1f 6 Jan 2014
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'
Nginx Debug Error Log
2017/02/22 11:29:27 [notice] 6335#6335: using the "epoll" event method
2017/02/22 11:29:27 [notice] 6335#6335: nginx/1.11.9
2017/02/22 11:29:27 [notice] 6335#6335: built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
2017/02/22 11:29:27 [notice] 6335#6335: OS: Linux 3.13.0-100-generic
2017/02/22 11:29:27 [notice] 6335#6335: getrlimit(RLIMIT_NOFILE): 1000000:1000000
2017/02/22 11:29:27 [notice] 6336#6336: start worker processes
2017/02/22 11:29:27 [notice] 6336#6336: start worker process 6337
2017/02/22 11:30:27 [info] 6337#6337: *1 client timed out (110: Connection timed out) while waiting for request, client: 117.34.28.13, server: 0.0.0.0:80
2017/02/22 11:30:49 [info] 6337#6337: *2 client timed out (110: Connection timed out) while waiting for request, client: 47.90.50.49, server: 0.0.0.0:80
2017/02/22 11:38:44 [info] 6337#6337: *3 client timed out (110: Connection timed out) while waiting for request, client: 183.61.236.14, server: 0.0.0.0:80
2017/02/22 11:38:44 [info] 6337#6337: *4 client timed out (110: Connection timed out) while waiting for request, client: 124.95.168.140, server: 0.0.0.0:80
2017/02/22 11:38:45 [info] 6337#6337: *5 client timed out (110: Connection timed out) while waiting for request, client: 61.182.137.6, server: 0.0.0.0:80
2017/02/22 11:38:46 [info] 6337#6337: *6 client timed out (110: Connection timed out) while waiting for request, client: 117.27.149.14, server: 0.0.0.0:80
2017/02/22 11:38:50 [info] 6337#6337: *7 client timed out (110: Connection timed out) while waiting for request, client: 42.236.7.68, server: 0.0.0.0:80
2017/02/22 11:38:58 [info] 6337#6337: *8 client timed out (110: Connection timed out) while waiting for request, client: 124.95.168.140, server: 0.0.0.0:80
2017/02/22 11:38:59 [info] 6337#6337: *9 client timed out (110: Connection timed out) while waiting for request, client: 61.182.137.6, server: 0.0.0.0:80
2017/02/22 11:38:59 [info] 6337#6337: *10 client timed out (110: Connection timed out) while waiting for request, client: 183.61.236.14, server: 0.0.0.0:80
2017/02/22 11:39:02 [info] 6337#6337: *11 client timed out (110: Connection timed out) while waiting for request, client: 117.27.149.14, server: 0.0.0.0:80
2017/02/22 11:39:12 [info] 6337#6337: *12 client timed out (110: Connection timed out) while waiting for request, client: 124.95.168.140, server: 0.0.0.0:80
2017/02/22 11:39:12 [info] 6337#6337: *13 client timed out (110: Connection timed out) while waiting for request, client: 61.182.137.6, server: 0.0.0.0:80
2017/02/22 11:39:15 [info] 6337#6337: *14 client timed out (110: Connection timed out) while waiting for request, client: 183.61.236.14, server: 0.0.0.0:80
相关阅读:
关于挂机游戏的问题
express compression中间件需要配合nginx使用吗?不能单独使用吗?
php抛出异常后捕获不到
npm run dev报错
为什么说druid是最好的数据库连接池
quick-cocos2d-x 3.6中如何调用webview
jQuery 源码中X-Requested-With header 的作用
input[type=file] 第一次点击它,并且点击取消的按钮,onchange事件不触发,那么如何获取该事件?
php实现16位的des加密
已知一个scala.reflect.runtime.universe.Type,如何把一个类型为Any的值转换为这个Type
webpack css分离打包后,图片的路径问题。
vscode用setting-sync插件为啥报这个?
servlet后台接收不到前端发来的post数据
为什么webpack-dev-server不更新?
怎样将文本域前面的字与文本域居中对齐?
安卓开发手柄的键值
Vue渲染简单数组?
bs4 .children打印出来的结果为什么是这样?
angular中的ajax可以设置async: true这个参数吗?
ab压测php+redis,为什么很快就挂掉了?