如何從 NGINX 中的子資料夾提供 VueJS 3 應用程式?
P粉312195700
P粉312195700 2024-03-26 15:35:24
0
1
375

我想從同一 NGINX 伺服器但不同的子資料夾提供多個 VueJS 3 應用程式。我偶然發現並嘗試了來自堆疊和網路的無數資源,但事情並沒有整合在一起。

我有三個應用程式和三種建置類型。

生產:mydomain.com/app1、mydomain.com/app2、mydomain.com/app3

暫存:mydomain.com/staging/app1、mydomain.com/staging/app2、mydomain.

P粉312195700
P粉312195700

全部回覆(1)
P粉940538947

試試這個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

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!