Nginx配置proxy_pass转发的/路径
请求原地址 :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 | server { listen 80 ; server_name crm6yy_proxy.xxx.com; location / { proxy_set_header Host $host; proxy_set_header X-Real-Ip $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http: //crm6yy.xxx.com/; } } |
正向代理
场景
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及端口即可
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?