upstream bowenpay_backend {
server 127.0.0.1:9002;
}
server {
listen 80;
server_name wx.bowenpay.com;
location = / {
root /var/www/wxweb/dist;
index index.html;
}
location ~* \.(html|htm )$ {
root /var/www/wxweb/dist;
index index.html;
}
location / {
proxy_pass http://bowenpay_backend;
proxy_set_header Host $http_host;
}
location ~* \.(css|js|jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|map|mp4|ogg|ogv|webm|htc )$ {
root /var/www/wxweb/dist;
index index.html;
expires 1M;
access_log off;
add_header Cache-Control "public";
}
}
整体思路:
1 )静态文件( html/css/js/图片 /字体等)直接去对应目录下访问
2 )其它( api 访问)代理到对应 api 服务的端口