Hallo zusammen!
Ich möchte unter einer Domain mehrere Shops installieren. Die Idee ist, dass es für verschiedene Länder jeweils eigene und unabhängige Shops gibt, z.B. shopdomain .com/de shopdomain .com/en etc.
Der Webserver läuft mit NGINX.
Ich habe Shopware 6.5.5.1 zu Testzwecken zweimal installiert, jeweils in ein eigenes Verzeichnis:
- /var/www/html/developer/dev-test
- /var/www/html/developer/dev-app1
In der NGINX conf läuft die erste Installation auf der Domain ohne Unterverzeichnis, also shopdomain .com → läuft einwandfrei, inkl. Backend.
Für die zweite Installation habe ich einen proxy eingerichtet. Nach dem gleichen Schema sollen weitere Installationen hinzukommen.
Meine NGINX conf sieht wie folgt aus:
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;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/gerwin-gesundheitsprodukte.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/gerwin-gesundheitsprodukte.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = gerwin-gesundheitsprodukte.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name gerwin-gesundheitsprodukte.com;
return 404; # managed by Certbot
}
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;
}
}
Auch der zweite Shop lässt sich aufrufen. Aber ich kann das Backend nicht öffnen. Es erscheint folgende Fehlermeldung:
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
Ich sehe grad den Wald vor lauter Bäumen nicht. Hat jemand einen Hinweis, was an meiner NGINX Konfiguration vielleicht nicht stimmt?
Gruß,
Dorina