I have the following configuration on Debian based on 2 servers:
-
On main server there are Apache2 and Magento 2 with Redis and Memcached.
-
On 2nd server there is Varnish which listens on
http://example.com:80
Everything works perfectly until I try to use https
.
I installed nginx on the 2nd server and configured it to work as SSL termination according to this tutorial.
Now:
http://example.com
works because it goes directly to Varnishhttps://example.com
ends with only text without css/js/images, because of the mixed content error below:
Error: "Mixed Content: The page at 'https:// example.com/' was loaded
over HTTPS, but requested an insecure stylesheet
'http://example.com/pub/static/frontend/Mycompany/Mytheme/en_US/mage/calendar.css'.
This request has been blocked; the content must be served over HTTPS."
Does it mean that it is not possible to use Magento 2 with Varnish over https?
Any advice?
Best Answer
Final I found the solution.
Replace the Base URL from
http://example.com/
to//example.com/
CAUTION! The change is not allowed in magento2 admin.
I made it in MySQL in table cron_config_data and record with path='web/unsecure/base_url'. After cache:clean and varnish restart everything works smoothly in frontend.
Unfortunately problem remains in Backend. Magento2 redirects to this url:
https://example.com/admin_mine/index/example.com/admin_mine/index/index/key/...
This last problem solved by simply change the Admin base url from Stores -> Configuration -> Advanced -> Admin -> Custom Admin URL =
https://example.com/