Nginx: обслуживать 2 реагирующих приложения в одном домене - PullRequest
0 голосов
/ 06 мая 2020

У меня есть 2 приложения для реагирования, и я пытаюсь обслуживать их с помощью их c stati c файлов с nginx в том же домене:

  • frontend.com / переходит в APP1
  • frontend.com / av переходит в APP2

Вот моя Nginx конфигурация, которую я попробовал:

server {
    listen 443 ssl http2;
    server_name frontend.com;

    set $rootpath /usr/share/nginx/html/frontend;
    set $rootpathAV /usr/share/nginx/html/av/frontend;

    location ^~  /av/static/ {
            root $rootpathAV/current/;
            rewrite ^/av/(.*)$ $1 break;
            try_files $uri /$uri =404;
    }

    location ^~  /static/ {
            root $rootpath/current/;
            try_files $uri /$uri =404;
    }

    location ^~  /av {
            root $rootpathAV/current/;
            rewrite ^/av/(.*)$ $1 break;
            try_files $uri $uri/ /index.html =404;
            include nginxconfig.d/ipallowed.conf;
    }

    location / {
            root $rootpath/current/;
            try_files $uri $uri/ /index.html;
            include nginxconfig.d/ipallowed.conf;
    }

    include nginxconfig.d/ssl.conf;
    include nginxconfig.d/general.conf;

}

С этой конфигурацией первое приложение отлично работает, но второе (av) не может получить свои файлы c stati из root которые я указал для него, он всегда пытается получить их из: /usr/share/nginx/html/frontend/current/static вместо: /usr/share/nginx/html/av/frontend/current/static

Может ли кто-нибудь мне с этим помочь?

...