多个单页面路由Nginx配置(备忘)

分类:技术来源:bobo最近更新:2021-12-06浏览:1591

sass端项目经常有控制台和管理后台两个系统。分别用单页面做的,如果启动两个端口有些浪费,用目录区分就好

server {
listen 8081;
server_name 127.0.0.1;
client_max_body_size 100M;
#sass端
location  / {
root  /home/chuanglan/yunger/web;
index index.html;
try_files $uri $uri/ /index.html;
if ($request_filename ~* .*\.(?:htm|html)$){
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
}
}

#管控后台
location /admin {
alias /home/chuanglan/yunger/admin;
try_files $uri $uri/ /admin/index.html;
if ($request_filename ~* .*\.(?:htm|html)$){
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
}
}

#admin代理
location ^~ /boss {
proxy_pass http://xx.xx.xx.xx:8098;
}
#sass控制台接口
location ^~ /console {
proxy_pass http://xx.xx.xx.xx:8099;
}
}