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,为什么很快就挂掉了?

nginx php多域名配置文件,配置文件,nginx_nginx多站点配置,无法通过域名访问,使用ip访问会跳转到其中一个站点,配置文件,nginx - phpStudy...相关推荐

  1. 域名访问和ip访问区别

    域名访问和ip访问区别 ip访问对应某一台确定的服务器: 域名访问相当于在ip访问的基础上,做了一个反向代理的中间功能.例如:百度,很多人会同时使用,如果使用的是同一台服务器的话,服务器估计会扛不住, ...

  2. nginx配置域名访问/禁止ip访问

    一 背景 为什么要禁止ip访问? 为了避免其他人把未备案的域名解析到自己的服务器IP,而导致服务器被断网,我们可以通过禁止使用ip访问的方法,防止此类事情的发生. 二 解决方法 修改配置文件nginx ...

  3. tomcat限制用域名访问 禁止 ip访问

    有时候会遇到服务器网站.只可以通过域名访问.而不允许ip访问.防止域名恶意解析,tomcat可以实现这个简单功能. 1,禁止ip访问项目 2,只允许绑定域名访问 环境:tomcat7  外网地址:11 ...

  4. apache 一个站点配置多个域名

    <VirtualHost *:80> ServerAdmin i@kuigg.com DocumentRoot /www/kuigg.com ServerName kuigg.com Se ...

  5. nginx 配置多个域名 指向不同服务_Nginx的几个常用配置和技巧

    文章列举了几个Nginx常见的,实用的,有趣的配置,希望看过之后能说一句:学到了! 一个站点配置多个域名 server { listen 80; server_name ops-coffee.cn b ...

  6. Nginx二级域名及多Server反向代理配置

    Nginx强大的正则表达式支持,可以使server_name的配置变得很灵活,如果你要做多用户博客,那么每个用户拥有自己的二级域名也就很容易实现了. 注:nginx反向代理同一ip多个域名,给head ...

  7. 01_Nginx安装,nginx下部署项目,nginx.conf配置文件修改,相关文件配置

     1.下载Nginx,进入Nginx下载地址:http://nginx.org/ 点击nginx-1.8.0,进入:http://nginx.org/en/download.html,下载文件: ...

  8. nginx之配置文件解读及虚拟主机配置

    文章目录 一.认识配置文件 1.整体结构 2.各"块"功能 3.最详细的配置文件解释 二.配置虚拟主机 1.什么是虚拟主机? 2.虚拟主机类型 3.配置虚拟主机   如果你还没有搭 ...

  9. nginx只允许域名访问,禁止ip访问

    背景: 为什么要禁止ip访问页面呢? 这样做是为了避免其他人把未备案的域名解析到自己的服务器IP,而导致服务器被断网,我们可以通过禁止使用ip访问的方法,防止此类事情的发生. 解决方法: 这里介绍修改 ...

最新文章

  1. 企业分布式微服务云SpringCloud SpringBoot mybatis - 服务消费者(Feign)
  2. strlen()函数 与 “\0“ 的关系 与 利用;strcmp()
  3. 具有中央异常处理和VO验证的Spring Data JPA –框架
  4. nfs需要开通什么端口_创业板开通需要什么条件?开通创业板门槛,要怎么样开通创业板?...
  5. django使用mysql事务处理_Django中MySQL事务的使用
  6. 安装Nvida 显示环境
  7. 递增输出链表结点,删除重复结点
  8. 笨办法学python3_月底送书!入门Python都在学的“笨办法”,出进阶篇了!
  9. 内存映射第一步:idmap swapper
  10. 笔记《深入浅出数据分析》上
  11. 2017 ACM-ICPC Asia Shenyang (ICPC亚洲沈阳赛区)
  12. 使用MSChart控件绘制图表。
  13. 海洋地球物理探测方法综述(二)
  14. ODBC数据源无法添加EXCEL驱动,显示存在系统错误代码126:找不到指定模块
  15. Stm32型号查阅手册
  16. JAVA JSP水费管理系统JSP电费管理系统JSP缴费管理系统JSP水费缴费系统JSP水电费管理
  17. python for循环求和_怎么在python中用for循环求和
  18. 使用cut命令将空格用作定界符
  19. java和数据库成绩管理系统,基于java与sql数据库技术的学生成绩管理系统 (4).doc...
  20. 软件测试中语句覆盖的优点,软件测试之测试覆盖率的基本策略

热门文章

  1. c#控制台模拟dos_超好用的C#控制台应用模板
  2. 【Deblurring by Realistic Blurring】阅读笔记
  3. 数位笔的笔芯磨损到什么程度需要更换?压感笔笔芯怎么更换?
  4. C++MYSQL:获取表结构:MYSQL_FEILD
  5. js:nodejs中的session(登陆验证)
  6. Anker 拓展坞连接网线经常断网问题
  7. Eclipse中如何调出Servers,这里教你一遍成功。
  8. 网络请求框架 -- 理解Https
  9. tomcat加白名单_[WebServer] Tomcat 配置访问限制:访问白名单和访问黑名单
  10. 使用RX方式模拟DoubanFm的登陆