由于nginx配置的问题,导致所有静态文件的读取都不经过后台,直接从vue工程中读取所致。正确的nginx配置如下:
server {
listen 80;
server_name test.163.cn;
error_log /var/log/nginx/project_error.log notice;
rewrite_log on;
location /prod-api/ {
#proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://111.111.111.111:8081/;
}
location ^~ /prod-api/profile/avatar/ {
proxy_set_header Host $http_host;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://111.111.111.111:8081/profile/avatar/;
}
location ~ .*\.(ico|json|properties|gif|jpg|jpeg|png|bmp|swf|js|css)$ {
root /home/ruoyi/deploy/project/;
autoindex on;
#设置缓存上面定义的后缀文件缓存到浏览器的生存时间
expires 3d;
}
location / {
root /home/ruoyi/deploy/project/;
autoindex on;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
}