http 代理 / 超时设置

最后更新于:2022-04-02 02:54:25

[TOC] ## http 代理 ``` location /foo { proxy_pass http://xxx.xxx.xxx.xxx:8080/foo; break; } ``` ### 带参数的正则代理 ``` location ~ ^/imapp/ { proxy_pass http://127.0.0.1:8081; break; } ``` 所有的 /imapp 请求转发到 8081 端口 ### 代理(设置超时,真实IP) ``` location /foo { proxy_pass http://xxx.xxx.xxx.xxx:8080/foo; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 300s; proxy_send_timeout 300s; proxy_read_timeout 300s; access_log /var/log/nginx/access.foo.log main; error_log /var/log/nginx/error.foo.log; break; } ```
';