在nginx.conf配置文件做如下配置
server {
listen 80;
server_name localhost;# 配置域名信息
root C:\project\myweb; # 静态页面根目录
#前端网站
location / {
try_files $uri $uri/ @router; #需要指向下面的'@router'否则会出现vue的路由在nginx中刷新出现
index index.html;#默认首页
}
#对应上面的'@router',主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
#因此需要rewrite到index.html中,然后交给路由在处理请求资源
location @router {
rewrite ^.*$ /index.html last;
}
#后台服务
location /sys {
proxy_pass http://127.0.0.1:8098/sys/;
}
}