Mixed Content Fehler seid SW 5.4 (Entfernung von "Überall SSL verwenden" / Mischbetrieb)

Hi Zusammen,

seid dem SW Update 5.4 bei dem die Funktion “Überall SSL verwenden” entfernt wurde, werden bei mir keine Inhalte mehr via https geladen. Das führt zu einem Mixed Content Fehler und der Browser spielt keine Bilder etc. mehr aus. Vor dem Update funktionierte alles problemlos und die Inhalte wurden auch via https geladen.

Mein Setup ist etwas spezieller:

Der Shop läuft mit nginx innerhalb eines Docker-Containers. Davor ist ein nginx reverse proxy geschalten, der reverse proxy leitet die requests intern (ohne ssl) zum Container. Daher hört der nginx Webserver im Container auch auf Port 80. Hier meine Nginx config im Container:

server {
    listen 80;
    server_name staging.livana.shop;
    root /var/www/html;

    client_max_body_size 24M;

    ## Author: Benjamin Cremer
    ## Shopware nginx rules.
    ## Heavily Inspired by https://github.com/perusio/drupal-with-nginx/
    ## Designed to be included in any server {} block.
    ## Please note that you need a PHP-FPM upstream configured in the http context, and its name set in the $fpm_upstream variable.
    ## https://github.com/bcremer/shopware-with-nginx

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    ## Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
    location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
    }

    ## Deny all attems to access possible configuration files
    location ~ \.(tpl|yml|ini|log)$ {
        deny all;
    }

    ## Deny access to media upload folder
    location ^~ /media/temp/ {
        deny all;
    }

    # Shopware caches and logs
    location ^~ /var/ {
        deny all;
    }

    # Deny access to root files
    location ~ (autoload\.php|composer\.(json|lock|phar)|CONTRIBUTING\.md|eula.*\.txt|license\.txt|README\.md|UPGRADE\.md)$ {
        return 404;
    }

    location ^~ /files/documents/ {
        deny all;
    }

    # Block direct access to ESDs, but allow the follwing download options:
    # * 'PHP' (slow)
    # * 'X-Accel' (optimized)
    # Also see http://wiki.shopware.com/ESD_detail_1116.html#Ab_Shopware_4.2.2
    location ^~ /files/552211cce724117c3178e3d22bec532ec/ {
        internal;
    }

    # Shopware install / update
    location /recovery/install {
        index index.php;
        try_files $uri /recovery/install/index.php$is_args$args;
    }

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

    location / {
        location ~* "^/themes/Frontend/Responsive/frontend/_public/vendors/fonts/open-sans-fontface/(?:.+)\.(?:ttf|eot|svg|woff)$" {
            expires max;
            add_header Cache-Control "public";
            access_log off;
            log_not_found off;
        }

        location ~* "^/themes/Frontend/Responsive/frontend/_public/src/fonts/(?:.+)\.(?:ttf|eot|svg|woff)$" {
            expires max;
            add_header Cache-Control "public";
            access_log off;
            log_not_found off;
        }

        location ~* "^/web/cache/(?:[0-9]{10})_(?:.+)\.(?:js|css)$" {
            expires max;
            add_header Cache-Control "public";
            access_log off;
            log_not_found off;
        }


        ## All static files will be served directly.
        location ~* ^.+\.(?:css|cur|js|jpe?g|gif|ico|png|svg|html)$ {
            ## Defining rewrite rules
            rewrite files/documents/.* /engine last;
            rewrite backend/media/(.*) /media/$1 last;

            expires 1w;
            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;

            ## Fallback to shopware
            ## comment in if needed
            try_files $uri /shopware.php?controller=Media&action=fallback;
        }

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

    ## XML Sitemap support.
    location = /sitemap.xml {
        log_not_found off;
        access_log off;
        try_files $uri @shopware;
    }

    ## XML SitemapMobile support.
    location = /sitemapMobile.xml {
        log_not_found off;
        access_log off;
        try_files $uri @shopware;
    }

    ## robots.txt support.
    location = /robots.txt {
        log_not_found off;
        access_log off;
        try_files $uri @shopware;
    }

    location @shopware {
        rewrite / /shopware.php;
    }

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
            return 404;
        }

        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

        fastcgi_pass php:9000;

    }
}

Was ich schon probiert habe:

  • Proxy Ip in der config.php (trustedproxies) eingefügt
  • $_SERVER[‘HTTP_X_FORWARDED_PROTO’] = ‘https’; in der config.php gesetzt

Weitere Info:

Ohne das ich trustedproxies setze oder $_SERVER[‘HTTP_X_FORWARDED_PROTO’] = ‘https’; setze steht standardmäßig laut SW Backend -> Systeminfos -> PHP

_SERVER[“HTTPS”] = no value (also leer)

_ENV[“HTTP_X_FORWARDED_PROTO”] = ‘https’;

 

Grundeinstellungen => Shops => Shop => “SSL verwenden” ist selbstverständlich aktiv.

 

Würde mich über Unterstützung sehr freuen.

Beste Grüße

Kevin

Problem hat sich gelöst. Lag wohl an einer falschen proxy Ip im trustedproxies Array.

Hier meine config.php falls jemand mit einem ähnlichem Setup auch auf das Problem stößt:

        array (
            'host' => 'mariadb',
            'port' => '3306',
            'username' => 'user',
            'password' => 'password',
            'dbname' => 'db',
        ),
    'trustedproxies' => array (
        '172.17.0.11',
    ),
);

Bei “172.17.0.11” natürlich die eigene IP des Containers einfügen. Findet ihr mit: 

docker inspect -f ‘{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ service_name

Achtet darauf das ihr eurem Nginx-Reverse-Proxy-Container eine static IP zugewiesen habt, sonst müsst ihr bei jedem neustart des Containers immer die IP anpassen.

LG Kevin