首页 > 解决方案 > 如何在一个域 NGINX 中设置两个应用程序?

问题描述

我有两个应用程序。

我在设置 NGINX 时遇到问题。每次我进入 LaravelVue 应用程序时,总是找不到资产,因为它总是在 nuxtjs 中访问 root。

如何配置它?

我的 nginx 看起来像这样

server {

        server_name mydomain.com;

        #nuxt
        location / {
                root /var/www/html/nuxt;

                proxy_pass http://localhost:8006;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
        }

        #laravel&vue
        location /client {
                root /var/www/html/laravue/public;

                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                #try_files $uri $uri/ /index.php?$query_string;

        }

        location /dashboard {
                root /var/www/html/laravue/public;

                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {
                 root /var/www/html/laravue/public;

                 try_files $uri =404;
                 fastcgi_split_path_info ^(.+\.php)(/.+)$;
                 fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                 fastcgi_index index.php;
                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                 include fastcgi_params;
         }


}

谢谢

标签: laravelvue.jsnginxnuxt.js

解决方案


推荐阅读