nginx配置访问控制、rewrite应用、nginx代理
来源:互联网 发布:流金网络官网 编辑:程序博客网 时间:2024/05/22 00:22
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;
}
}
阅读全文
0 0
- nginx配置访问控制、rewrite应用、nginx代理
- Nginx 访问控制配置
- Nginx的rewrite应用
- nginx rtmp配置访问控制
- NGINX的REWRITE配置
- nginx 配置 rewrite 跳转
- nginx rewrite配置
- nginx rewrite 配置
- nginx 配置说明 rewrite
- nginx rewrite 配置实例
- Nginx的Rewrite配置
- nginx配置ThinkPHP Rewrite
- Nginx的Rewrite配置
- Nginx rewrite配置规则
- Nginx配置基础-rewrite
- Nginx之rewrite配置
- Nginx 配置应用日志访问
- Nginx配置反向代理访问 Gitlab
- 数据可视化神器Tableau学习小结2
- [解惑]JavaScript事件机制
- SQL SERVER 2014 安装总结
- C-Free 5.0的使用
- 什么是分层自动化测试
- nginx配置访问控制、rewrite应用、nginx代理
- LeetCode 46. Permutations (Medium)
- 攻破 JAVA NIO 技术壁垒( 上 )
- 破解SHA-1密码
- 浏览器访问网页的详细内部过程
- java中数组的基本操作
- python学习笔记2:print的使用中的一些问题
- Hbase(1)基础篇
- Lintcode142 O(1) Check Power Of 2 solution 题解