nginx代理
16lz
2021-03-30
nginx正向代理反向代理
正向代理:代理对象是客服端
反向代理:代理对象是服务端
区别所代理的对象不一样
#配置语法Syntax: proxy_pass URL;Default:-ContextLlocation,if in location,limit_except
#配置#192.168.0.250 (代理服务器)resolver 8.8.8.8;location / { #default_type text/html; #return 200 http_host:$http_host<br>request_uri:$request_uri; proxy_set_header X-Forwarded-For 250.cn; proxy_pass http://$http_host$request_uri;}#192.168.0.251location / { default_type text/html;if ($http_x_forwarded_for != "250.cn" ){ return 200 http_x_forwarded_for:$http_x_forwarded_for; } index index.html index.htm; autoindex on; autoindex_exact_size off; autoindex_localtime on; }
本地访问
http://251.cn/
客户端设置250的代理(chrome可通过SwitchySharp)
才能真正访问到
/http:http:http:http: cannot have URI part location given by regular expression, or inside named location, or inside statement, or inside block /usr/local/nginx/conf/nginx.conf:
待续.....
©著作权归作者所有:来自51CTO博客作者hkui2010的原创作品,如需转载,请注明出处,否则将追究法律责任
更多相关文章
- 部分无公网环境下使用yum源代理
- 换IP
- LNMP架构应用实战—Nginx反向代理负载均衡配置
- 模拟器如何换IP
- Apache服务的反向代理及负载均衡配置
- Nginx架构详解(二):nginx反向代理配置
- 反向代理服务器:为什么用,怎么用,如何用?
- nginx反向代理443端口
- 前端用Ajax实现数据异步加载,无刷新分页(核心思路为 事件派发+事件