负载均衡、反向代理
使用
upstream backend { server 192.168.7.10; server 192.168.7.11; } server { listen 80; server_name localhost; location / { proxy_pass http://backend; } }
proxy_pass指令
目录环境: /test.html /html/test.html
访问 http://192.168.7.201/html/a.html
#配置1,跳转路径末尾不带"/" location ^~ /html { proxy_pass ; }
跳转前不会去掉location指定的前缀,返回的页面为 /html/test.html
#配置2,跳转路径末尾不带"/" location ^~ /html { proxy_pass ; }
跳转前会去掉location匹配的前缀,返回的页面为/test.html
proxy_cache缓存
此功能不能和proxy_store一起使用,只能二选一
proxy_store镜象
此功能不能和proxy_cache一起使用,只能二选一,被镜象的文件目录结构和后端服务器一致
转载于:https://my.oschina.net/daoying/blog/365216