server {
listen 80;
listen 443 ssl http2;
server_name www.demo.com;
if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
# 前端
location / {
root /data/wwwroot/www;
index index.html;
try_files $uri $uri/ /index.html;
}
# 后台
location ^~/admin {
alias /data/wwwroot/admin;
try_files $uri $uri/ /admin/index.html;
}
# 数据接口
location /api {
proxy_pass http://127.0.0.1:5000;
}
}