1
2
3
4
5
6
7
8
9
10
|
[root@localhost vhosts]
# vi default.conf
server
{
listen 80 default_server;
server_name localhost;
index index.html index.htm index.php;
root
/usr/local/nginx/html
;
deny all;
allow 2.2.2.2;
}
|
1
2
3
4
5
6
7
|
[root@localhost vhosts]
# curl -x127.0.0.1:80 192.168.20.30/index.html -I
HTTP
/1
.1 403 Forbidden
Server: nginx
/1
.6.2
Date: Fri, 15 May 2015 08:46:05 GMT
Content-Type: text
/html
Content-Length: 168
Connection: keep-alive
|
1
2
3
4
|
# cat /usr/local/nginx/conf/deny.ip
deny 192.168.20.10;
deny 192.168.20.11;
deny 192.168.10.0
/24
;
|
1
2
3
4
5
6
7
|
[root@localhost vhosts]
# curl -x127.0.0.1:80 -A "aabingbot/2.0ss" www.111.com -I
HTTP
/1
.1 403 Forbidden
Server: nginx
/1
.6.2
Date: Fri, 15 May 2015 21:09:35 GMT
Content-Type: text
/html
Content-Length: 168
Connection: keep-alive
|
1
2
3
4
5
6
7
|
[root@localhost vhosts]
# curl -x127.0.0.1:80 -A "MSIE 7.0aa" www.111.com -I
HTTP
/1
.1 403 Forbidden
Server: nginx
/1
.6.2
Date: Fri, 15 May 2015 21:13:50 GMT
Content-Type: text
/html
Content-Length: 570
Connection: keep-alive
|
1
2
3
4
5
6
7
|
[root@localhost vhosts]
# curl -x127.0.0.1:80 192.168.20.30/index.html -I
HTTP
/1
.1 403 Forbidden
Server: nginx
/1
.6.2
Date: Fri, 15 May 2015 09:15:27 GMT
Content-Type: text
/html
Content-Length: 168
Connection: keep-alive
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@localhost vhosts]
# cat 111.conf
server
{
listen 80;
server_name www.aaa.com aaa.com;
index index.html index.htm index.php;
root
/data/www2
;
rewrite ^/(.*)$
/aaa/
$1 redirect;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:
/tmp/php-fcgi-www2
.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
/data/www2
$fastcgi_script_name;
}
}
|
1
2
3
4
5
6
7
8
9
|
[root@localhost vhosts]
# curl -x127.0.0.1:80 www.aaa.com/asdfasdfa -I
HTTP
/1
.1 302 Moved Temporarily
Server: nginx
/1
.6.2
Date: Fri, 15 May 2015 09:54:10 GMT
Content-Type: text
/html
Content-Length: 160
Location:
http:
//www
.aaa.com
/aaa/asdfasdfa
Connection: keep-alive
|
1
2
3
4
5
6
7
8
9
10
11
|
[root@localhost vhosts]
# cat proxy.conf
server {
listen 80;
server_name
location / {
proxy_pass http:
//180
.97.33.108/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
upstream bbb
{
server 180.97.33.108:80;
server 180.97.33.107:80;
}
server {
listen 80;
server_name
location / {
proxy_pass http:
//bbb/
;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
|