比如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;
}
}
|