1、在/etc/nginx/sites-available/中新建一个文件比如timeless
server { listen 80; listen [::]:80; error_log /var/log/nginx/timeless_error.log; access_log /var/log/nginx/timeless_access.log; # 项目路径 root /Projects/Vue3/xxxxx; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; server_name domain.com www.domain.com; # vue3的项目必须加try_files $uri $uri/ /index.html; location / { try_files $uri $uri/ /index.html; } # 反向代理,接口转发 location /api/ { proxy_pass http://xxxx.com/; } }
2、然后在/etc/nginx/sites-enabled中,把该文件软链过去
ln -s ../sites-available/timeless
3、重启
systemctl reload nginx systemctl restart nginx
Ubuntu24.04中Nginx 配置vue3项目
| Title | Ubuntu24.04中Nginx 配置vue3项目 |
|---|---|
| Framework | Ubuntu |
| User | wy8817399@vip.qq.com |
| Id | 21 |
| Created | 1/13/26, 8:42 AM |
| Modified | 1/22/26, 10:41 AM |
| Published | Yes |
Content