1.upstream配置
upstream service{
server ip:port;
}
2.location 配置代理proxy_pass 指向upstream , 其中xmmc是指项目名称
location /xmmc {
proxy_read_timeout 150;
if ($http_referer ~* "www.baidu.com") {
return 403;
}
proxy_pass http://service;
}
3.location配置页面,我的页面文件是放到html文件夹下,xmmc-web就是静态页面存放的文件夹名称
location /xmmc-web {
root html;
index index.html index.htm;
}
提示:3和2放的顺序不能反,否则会报404