🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
这个[模块][1]的使用方法和fastcgi模块很相似. ## 配置示例 [参考][2] [参考][3] ~~~bash http{ proxy_temp_path path /tmp/nginx_temp_cache 1 2 proxy_cache_path /tmp/nginx_cache levels=1:2 keys_zone=nginx_cache:10m; proxy_cache_key "$scheme$request_method$host$request_uri"; proxy_connect_timeout 300; proxy_send_timeout 300; proxy_read_timeout 300; proxy_buffer_size 64k; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; proxy_temp_file_write_size 128k; proxy_intercept_errors on; server{ ... location /url/ { proxy_pass remote_php_ip/new/url proxy_cache nginx_cache; proxy_cache_valid 200 302 1m; proxy_cache_valid 404 1m; proxy_set_header X-Cache "$upstream_cache_status From $host"; } ... } } ~~~ >[info]upstream_cache_status ## 常用参数 ~~~ proxy_pass http://{SERVER_IP|UPSTREAM_NAME}/uri proxy_cache_path path [levels=levels] keys_zone=name:size [inactive=time] [max_size=size] ; proxy_cache zone_name; proxy_cache_valid [code] time; proxy_cache_method GET|HEAD proxy_cache_use_stale error timeout ... proxy_cache_min_uses 1; proxy_cache_bypass string: 设置在何种情形下nginx将不从cache取数据的; $cookie_nocache $arg_nocache $http_authorization proxy_set_header X-Cache $upstream_cache_status ~~~ >[danger] 注意 ~~~ location /forume/ { proxy_pass http://192.168.8.30/bbs/; } http://192.168.8.30/forum/ --> http://192.168.8.30/bbs/ 或者,使用正则匹配时,比较特殊,ip后边不能跟url,此处直接映射为http://192.168.8.30/forume/ location ~* ^/forume/ { proxy_pass http://192.168.8.30; } http://192.168.8.30/forum/ --> http://192.168.8.30/forum/ ~~~ [1]:http://nginx.org/en/docs/http/ngx_http_proxy_module.html [2]:https://zhangge.net/5067.html [3]:https://zhangge.net/5042.html