하위 폴더를 사용하여 여러 Symfony 설치를 위한 NGINX 구성

하위 폴더를 사용하여 여러 Symfony 설치를 위한 NGINX 구성

내 도메인에서 Shopware 설치(버전 6.5.5.1)가 실행되고 있습니다. 동일한 도메인(다른 언어/국가용)을 사용하여 독립적인 Shopware 설치를 더 추가하고 싶습니다.

예를 들어 mydomain.com, mydomain.com/de, mydomain.com/en 등입니다.

두 개의 독립적인 설치가 있습니다.

  1. /var/www/html/developer/dev-test(gerwin-gesundheitsprodukte.com)

  2. /var/www/html/developer/dev-app1(gerwin-gesundheitsprodukte.com/app1)

백엔드를 포함하여 첫 번째 설치(gerwin-gesundheitsprodukte.com)가 제대로 실행되고 있습니다.

두 번째 Shopware 설치에서는 역방향 프록시(proxy_pass 127.0.0.1:81)를 사용하여 NGINX 구성을 확장하려고 했습니다.

두 번째 설치의 상점(gerwin-gesundheitsprodukte.com/app1)도 열리지만 백엔드(gerwin-gesundheitsprodukte.com/app1/admin)에 액세스하려고 하면 오류가 발생합니다.

Shopware\Administration\Controller\AdministrationController::index(): Argument #2 ($context) must be of type Shopware\Core\Framework\Context, null given, called in /var/www/html/developer/dev-app1/vendor/symfony/http-kernel/HttpKernel.php on line 182

$context일부 정보( )가 프록시를 통과하지 못하는 것 같은데요 ?

내 conf 파일에 어떤 문제가 있으며 일반적으로 이를 위해 Proxy_pass를 사용하는 접근 방식이 올바른가요?

내 구성의 관련 부분:

server {

    index index.php index.html;
    server_name gerwin-gesundheitsprodukte.com;

    client_max_body_size 128M;

    location ^~ /app1 {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_pass http://127.0.0.1:81;
        proxy_redirect off;
    }
#rest is Shopware standard config for first installation
}

server {
#the server block for the second installation
    listen 81;
    server_name 127.0.0.1;

    set $subdir_root /var/www/html/developer/dev-app1/public;
    root $subdir_root;

    rewrite ^/app1(.*)$ /$1 break;
    sub_filter "https://gerwin-gesundheitsprodukte.com/" "https://gerwin-gesundheitsprodukte.com/app1/";
    sub_filter_once off;

#rest of the config
}

전체 conf는 다음과 같습니다.

server {

    index index.php index.html;
    server_name gerwin-gesundheitsprodukte.com;

    client_max_body_size 128M;

    location ^~ /app1 {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_pass http://127.0.0.1:81;
        proxy_redirect off;
    }

    root /var/www/html/developer/dev-test/public;

    # Shopware update
    location /recovery/update/ {
        location /recovery/update/assets {
        }
        if (!-e $request_filename){
            rewrite . /recovery/update/index.php last;
        }
    }

    # new for Shopware 6.5
    location /shopware-installer.phar.php {
        try_files $uri /shopware-installer.phar.php$is_args$args;
    }

    location ~* ^.+\.(?:css|cur|js|jpe?g|gif|ico|png|svg|webp|html|woff|woff2|xml)$ {
        expires 1y;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";

        access_log off;

        # The directive enables or disables messages in error_log about files not found on disk.
        log_not_found off;

        tcp_nodelay off;

        ## Set the OS file cache.
        open_file_cache max=3000 inactive=120s;
        open_file_cache_valid 45s;
        open_file_cache_min_uses 2;
        open_file_cache_errors off;

        try_files $uri /index.php$is_args$args;
    }

    location ~* ^.+\.svg$ {
        add_header Content-Security-Policy "script-src 'none'";
    }

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi.conf;
        fastcgi_param HTTP_PROXY "";
        fastcgi_buffers 8 16k;
        fastcgi_buffer_size 32k;
        proxy_connect_timeout 300s;
        proxy_send_timeout 300s;
        proxy_read_timeout 300s;
        send_timeout 300s; 
        client_body_buffer_size 128k;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        http2_push_preload on;
    }

}


server {
    # Virtual host for web application 1:
    # - Only local (127.0.0.1), cannot be addressed directly (without gateway host).
    # - Listens on port 81 (HTTP) - IPv4 and IPv6.
    # - Is capable of serving requests for local IP address 127.0.0.1.

    listen 81;
    server_name 127.0.0.1;

    set $subdir_root /var/www/html/developer/dev-app1/public;
    root $subdir_root;

    rewrite ^/app1(.*)$ /$1 break;
    sub_filter "https://gerwin-gesundheitsprodukte.com/" "https://gerwin-gesundheitsprodukte.com/app1/";
    sub_filter_once off;


    # Shopware update
    location /recovery/update/ {
        location /recovery/update/assets {
        }
        if (!-e $request_filename){
            rewrite . /recovery/update/index.php last;
        }
    }

    # new for Shopware 6.5
    location /shopware-installer.phar.php {
        try_files $uri /shopware-installer.phar.php$is_args$args;
    }

    location ~* ^.+\.(?:css|cur|js|jpe?g|gif|ico|png|svg|webp|html|woff|woff2|xml)$ {
        expires 1y;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";

        access_log off;

        # The directive enables or disables messages in error_log about files not found on disk.
        log_not_found off;

        tcp_nodelay off;

        ## Set the OS file cache.
        open_file_cache max=3000 inactive=120s;
        open_file_cache_valid 45s;
        open_file_cache_min_uses 2;
        open_file_cache_errors off;

        try_files $uri /index.php$is_args$args;
    }

    location ~* ^.+\.svg$ {
        add_header Content-Security-Policy "script-src 'none'";
    }

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi.conf;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_param DOCUMENT_ROOT $subdir_root;
        fastcgi_param HTTPS on;
        fastcgi_param HTTP_PROXY "";
        fastcgi_buffers 8 16k;
        fastcgi_buffer_size 32k;
        proxy_connect_timeout 300s;
        proxy_send_timeout 300s;
        proxy_read_timeout 300s;
        send_timeout 300s;
        client_body_buffer_size 128k;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        http2_push_preload on;
    }

}

관련 정보