请求原地址 :http://servername/static_js/test.html
location ^~ /static_js/ { proxy_cache js_cache; proxy_set_header Host js.test.com; proxy_pass http://js.test.com/; } 或者 使用rewrite location ^~ /static_js/ { proxy_cache js_cache; proxy_set_header Host js.test.com; rewrite /static_js/(.+)$ /$1 break; proxy_pass http://js.test.com; }
代理成 http://js.test.com/test.html
location ^~ /static_js/ { proxy_cache js_cache; proxy_set_header Host js.test.com; proxy_pass http://js.test.com; }
代理成 http://js.test.com/static_js/test.htm
域名跳转 访问 crm6yy_proxy.xxx.com 跳转到 crm6yy.xxx.com
1 2 3 4 5 6 7 8 9 10 11 |
|
正向代理
场景
A 不能上外网
B 能上外网 (A和B可以互相访问)
C 外面的网站 http://www.baidu.com
B上nginx配置如下代码
resolver 8.8.8.8; server { listen 8090; location / { proxy_pass $scheme://$http_host$request_uri; } }
使用:
在A机器访问:
或者 curl -x B:8090 -k "C"
或者 export http_proxy="http://B:8090"
或者windows下:在internet选项->连接->局域网设置->代理服务器 填入ip及端口即可