ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## proxy_pass指令 1. 由http_proxy模块提供(ngx_http_proxy_module); 2. 默认已被编译进nginx; 3. 禁用须通过--without-http_proxy_module; ## proxy_pass语法结构 语法: ``` proxy_pass URL; ``` URL参数规则: 1. URL开头必须以http或https开头; 2. URL中可以携带变量; 3. URL中是否带URI,会影响发往上游请求的URL; 默认值: ``` 无 ``` 上下文: ``` location | if | limit_except ``` 示例: ``` proxy_pass http://127.0.0.1:8080; proxy_pass http://127.0.0.1:8090/proxy; ``` ## 实例 1. 先配置一台应用服务器,可访问的资源是192.168.33.10/proxy; 2. 本地nginx配置: ``` upstream back_end{ server 192.168.33.10 weight=3 max_conns=1000 fail_timeout=10s max_fails=2; keepalive 32; keepalive_requests 50; keepalive_timeout 30s; } server { listen 80; server_name website.com; charset utf-8; root html; location /pass { proxy_pass http://back_end/proxy; //proxy_pass的URL必须是http或https开头的,back_end对应上面配置的upstream上游服务器名称,因为访问的URI是/proxy,所以后面要加上; } ``` 3. 结果:访问成功 ![](https://img.kancloud.cn/bb/e1/bbe1cb364c2bcfda50442cdac6f9ebef_722x148.png)