04: nginx部署vue

时间:2023-03-08 22:04:34
04: nginx部署vue

1.1 基本配置

server {
listen 9000;
server_name 1.1.1.3;
#access_log logs/access_example.log main;
root /home/work/project/frontopwf/dist;
location / {
try_files $uri $uri/ @router;
}
location @router {
rewrite ^.*$ /index.html last;
}
}

#前后端分离nginx配置

        server {
listen 9000;
server_name www.example.cn;
access_log /home/work/logs/vue_access.log main;
root /home/work/project/frontopwf/dist;
location / {
try_files $uri $uri/ @router;
}
location @router {
rewrite ^.*$ /index.html last;
}
} server {
listen 8000;
server_name www.example.cn;
access_log /home/work/logs/workorder_access.log main;
location / {
proxy_pass http://127.0.0.1:8001;
}
}