标签:80端口 stat col main 3.2 strong forward 识别 pass
正向代理代理的对象是客户端
反向代理代理的对象是服务端
举例说下nginx作为正向代理作访问控制
server{ listen 80; server_name localhost jeson.gaosf.com; access_log /var/log/nginx/log/host.access.log main; location /{ if($http_x_forwarded_for !~* "^116\.62\.103\.228"){ return 403; } root /opt/app/code; index index.html index.htm; } }
利用http_x_forwarded_for 来识别是不是116.62.103.228这个ip,不是的话就返回403
反向代理的例子:
在/etc/nginx/conf.d下的realserver.conf里面
server{ listen 8080; server_name localhost jeson.gaosf.com; access_log /var/log/nginx/log/serve.access.log main; location /{ root /opt/app/code2; index index.html index.htm; } }
在/opt/app/code2下有个test_proxy.html文件
在/etc/nginx/conf.d下的fx_proxy.conf里面
server{ listen 80; server_name localhost jeson.gaosf.com; access_log /var/log/nginx/log/host.access.log main; location /{ root /usr/share/nginx/html; index index.html index.htm; } //当匹配test_proxy.html,会代理8080端口 location ~/test_proxy.html${ proxy_pass http://127.0.0.1:8080; } }
然后查看下
netstat -luntp|grep nginx
查看下状态
标签:80端口 stat col main 3.2 strong forward 识别 pass
原文地址:https://www.cnblogs.com/gaosf/p/10223804.html