VPS侦探论坛

 找回密码
 注册
查看: 4926|回复: 5

SSL证书配置后怎样设置才能一个站点启用,另一个站点不启用?

[复制链接]
发表于 2016-1-23 15:29:28 | 显示全部楼层 |阅读模式

如题,现在的状况是这样的,用vhost 添加了两个域名,例如分别是A.com和B.com,A.com配置了SSL证书,HTTPS访问正常,但B.com如果通过HTTPS访问,内容就会显示A.com的内容,HTTP访问则一切正常,请问这种问题应该怎么配置才能解决,B.com不想启用HTTPS访问,谢谢。
A.com的配置如下
  1. server
  2.         {
  3.                 listen 80;
  4.                 listen 443 ssl;
  5.                 #listen [::]:80;
  6.                 ssl on;
  7.                   ssl_certificate /root/A.com.crt;
  8.                   ssl_certificate_key /root/A.com.key;
  9.                 server_name www.A.com A.com;
  10.                 index index.html index.htm index.php default.html default.htm default.php;
  11.                 root  /home/wwwroot/www.A.com;

  12.                 include wordpress.conf;
  13.                 #error_page   404   /404.html;
  14.                 location ~ [^/].php(/|$)
  15.                         {
  16.                                 # comment try_files $uri =404; to enable pathinfo
  17.                                 try_files $uri =404;
  18.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  19.                                 fastcgi_index index.php;
  20.                                 include fastcgi.conf;
  21.                                 #include pathinfo.conf;
  22.                         }

  23.                 location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
  24.                         {
  25.                                 expires      30d;
  26.                         }

  27.                 location ~ .*.(js|css)?$
  28.                         {
  29.                                 expires      12h;
  30.                         }

  31.                 access_log  /home/wwwlogs/www.A.com.log  access;
  32.         }
复制代码
B.com的配置如下
  1. server
  2.         {
  3.                 listen 80;
  4.                 #listen [::]:80;
  5.                 server_name www.B.com B.com;
  6.                 index index.html index.htm index.php default.html default.htm default.php;
  7.                 root  /home/wwwroot/www.B.com;

  8.                 include wordpress.conf;
  9.                 #error_page   404   /404.html;
  10.                 location ~ [^/].php(/|$)
  11.                         {
  12.                                 # comment try_files $uri =404; to enable pathinfo
  13.                                 try_files $uri =404;
  14.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  15.                                 fastcgi_index index.php;
  16.                                 include fastcgi.conf;
  17.                                 #include pathinfo.conf;
  18.                         }

  19.                 location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
  20.                         {
  21.                                 expires      30d;
  22.                         }

  23.                 location ~ .*.(js|css)?$
  24.                         {
  25.                                 expires      12h;
  26.                         }

  27.                 access_log off;
  28.         }
复制代码

[ 本帖最后由 laibokeadd 于 2016-1-23 15:33 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-1-23 20:05:01 | 显示全部楼层


如果你只设置了一个https,所有未绑定https的域名的访问都会是你那一个默认的https站点

不想让其访问可以创建一个该域名的https配置,里面加上return 444;
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2016-1-27 18:45:52 | 显示全部楼层

回复 2# 的帖子


多谢解答,我试试去。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-4-7 10:04:36 | 显示全部楼层

回复 2# 的帖子




可以在未绑定https的下面加一个server 443 然后写上301跳转到80上吗?
这个方法是否可行
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2016-4-7 10:17:23 | 显示全部楼层

回复 4# 的帖子


只listen 443端口可以,但要用https那是不行的

军哥运维代购:http://shop63846532.taobao.com/

发表于 2016-4-7 12:00:04 | 显示全部楼层

原帖由 Uni9K1ng 于 2016-4-7 10:04 发表
可以在未绑定https的下面加一个server 443 然后写上301跳转到80上吗?
这个方法是否可行


你这个问题解决了么?  修改后具体写的是301还是啥?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-29 03:34 , Processed in 0.026816 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表