我想從同一 NGINX 伺服器但不同的子資料夾提供多個 VueJS 3 應用程式。我偶然發現並嘗試了來自堆疊和網路的無數資源,但事情並沒有整合在一起。
我有三個應用程式和三種建置類型。
生產:mydomain.com/app1、mydomain.com/app2、mydomain.com/app3
暫存:mydomain.com/staging/app1、mydomain.com/staging/app2、mydomain.
試試這個conf
server { listen 80; listen [::]:80; # SSL configuration # #listen 443 ssl; #listen [::]:443 ssl; #ssl_certificate /etc/letsencrypt/live/your-domain/fullchain.pem; #ssl_certificate_key /etc/letsencrypt/live/your-domain/privkey.pem; # #ssl_dhparam /etc/letsencrypt/live/dhparam/dhparam.pem; #ssl_protocols TLSv1.2; #ssl_prefer_server_ciphers on; #ssl_ciphers 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA'; #add_header X-Frame-Options DENY; root /var/www/proyect-vue/dist; # Add index.php to the list if you are using PHP index index.html index.htm index.php; server_name your-domain; location / { try_files $uri $uri/ /index.html; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one location ~ /\.ht { deny all; } }
現在,您可以使用 git 複製 /var/www/ 中的儲存庫並輸入 npm run build
試試這個conf
#現在,您可以使用 git 複製 /var/www/ 中的儲存庫並輸入 npm run build