首页 > Web开发 > 详细

禁止以ip方式访问网站

时间:2014-02-19 16:12:19      阅读:367      评论:0      收藏:0      [点我收藏+]

比如192.168.1.125是我的服务器地址,域名是www.bubuko.com,我想只允许用户通过域名访问,而不允许用户通过ip访问,所有通过ip访问的都跳转到域名,第一个server部分为起作用的配置代码

 

nginx配置如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
server {
        server_name 80default;
        server_name _;
        rewrite ^(.*) http://www.bubuko.com;
        }
 
server {
 
        server_name localhost www.bubuko.com;
 
        root /usr/share/nginx/www;
        index index.html index.htm;
 
        location / {
                index index.php;
                try_files$uri$uri/ /index.html;
        }
 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
 
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                includefastcgi_params;
        }
 
}

禁止以ip方式访问网站

原文:http://www.cnblogs.com/quinnxu/p/3554866.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!