Magento + Turpentine + SSL only generates HTTP URLs

1k Views Asked by At

I'm pulling my hair out over this problem so I'd really appreciate some help :/

I'm using Turpentine with Magento 1.7 CE and Varnish 3, which works fine. Now I wanted to add SSL encryption wich doesn't work so fine.

The SSL encryption is terminated by Pound (listening on 443) then the data is served to Varnish (listening on 6081) and finally to nginx (8080). The problem is that all generated URLS (product links, categories, ...) are generated with HTTP, not HTTPS.

I tried to set the unsecure base url to https, but that broke my site completely (I had a 404 "embed-loop" which never stopped loading).

SSL Offloading appears to work because all resources are loaded with HTTPS (if I mess with the SSL Offloading setting in Magento I get warnings about mixed content).

phpinfo tells me about HTTPS:

[...]
_SERVER["HTTPS"] on
_SERVER["HTTP_SSL_OFFLOADED"] 1
[...]

My configuration:

Magento (the most important parts I think):

Auto-redirect to Base URL: No
Use Web Server Rewrites: Yes
Unsecure Base URL: http://myurl.com
Secure Base URL: https://myurl.com
Use Secure URLs in Frontend: Yes
Offloader Header: HTTP_SSL_OFFLOADED

Pound:

ListenHTTPS
    Address 0.0.0.0
    Port    443
    Cert    "/path/to/my/cert.pem"
    xHTTP   2
    RewriteLocation 1
    Ciphers "RC4:!SSLv2:!ADH:!aNULL:!eNULL:!NULL:!LOW:!EXP"
    AddHeader "Ssl-Offloaded: 1"
End

Service
    BackEnd
        Address 127.0.0.1
        Port    6081
    End
End

Varnish uses the Turpentine-Config (which works fine without SSL)

nginx:

server {
        listen 8080 default_server;

        root /var/www/mysite.at;

        index index.php;

        server_name _;

        location / {
                try_files $uri $uri/ /index.php;
        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/www;
        }


        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;

                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;

                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
               fastcgi_param HTTPS on;
        }

        location ~ /\.ht {
                deny all;
        }
}

I'm really out of ideas :( I'd gladly provide more details about my configuration if needed.

1

There are 1 best solutions below

0
On BEST ANSWER

It turned out that I had multiple issues.

  1. nginx config for "location /":

    location / {
            try_files $uri $uri/ @handler;
    }
    
    location @handler {
            rewrite / /index.php;
    }
    

Without that no ajax calls would work.

  1. unsecure base url in Magento config needs to include "https"

  2. Turpentine has to use HTTP URLs for ESI, not HTTPS. The necessary changes are shown in this commit:

https://github.com/eth8505/magento-turpentine/commit/575f499382217f0013eaf097fd79ceddec0b4381