VPS侦探论坛

 找回密码
 注册
查看: 4043|回复: 2

请问网站使用阿里云证书设置好https后如何禁止ip访问

[复制链接]
发表于 2017-5-23 01:32:25 | 显示全部楼层 |阅读模式

没设置https之前,是server {
       listen 80 default;  
       return 403;  
   }
这样就可以了,域名正常使用80端口。

设置了阿里云的https之后。
域名设置:
server
{
listen 80;
#listen [::]:80;
server_name www.ilaodao.com;
return 301 https://$server_name$request_uri;
}

server {  
listen 443;
#listen [::]:443;
server_name www.ilaodao.com;
index index.html index.htm index.php default.html default.htm default.php;
root  /home/wwwroot/rootx;
include none.conf;
#error_page   404   /404.html;
ssl on;
ssl_certificate   /cert/214100445453434.pem;
ssl_certificate_key  /cert/214100445453434.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
# try_files $uri =404;
fastcgi_pass  unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
include pathinfo.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires      30d;
}
location ~ .*\.(js|css)?$
{
expires      12h;
}
}
结果:https://+ip虽然提示不安全但是会访问我的域名下的内容, ip:443访问会报400错误。


为了屏蔽ip访问,于是设置:
nginx.conf设置:
server {        listen 443 default;  
      return 403;  
   }
同样方法设置443,会导致正常域名的https+域名一样无法访问。

请问军哥有什么办法屏蔽https://+ip, ip:443却不影响正常https://+域名的使用。谢谢。

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


禁止ip访问的443 default_server 上也要按ssl虚拟主机的设置设置上证书、key等设置才行
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2017-5-23 11:02:48 | 显示全部楼层

回复 2# 的帖子


感谢军哥,这个问题深夜到处搜了两个小时都没找到答案。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-26 03:30 , Processed in 0.025235 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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