0

What do I have:

  • Drupal 8.6.2
  • Domain Access
  • Language modules
  • Cloudflare with https

Problem:

If in URL language detection option (/admin/config/regional/language/detection/url) I have "Path prefix" - everything works fine.

Party starts, when I change it to "Domain" - every ajax request on any subdomain is trying to get through http instead of https and I can see "mixed content error" in console, so these requests are being blocked and website is malfunctioning. I cant use views propeerly, upload files through Plupload, use autocomplete forms, change some settings etc.

If I change it back to prefix - ajax works great again.

For prefix I have site.com for default language and site.com/en - for english. For domain setting: site.com - default and en.site.com is english version.

In Domain Access settings I've tried to set all possible URL schemas (http, https and variable) - no change. In Cloudflare settings I have speacial rules, redirecting every request from http to https (I set up CF's https for dozen of websites, I know how to do it).

If I set back to prefix and go to en.site.com (it still works as an alias for the main domain) ajax works fine, so this is not something about server or background settings - it's just Drupal messing around.

I could run it with prefix, but for SEO purposes it is better to use subdomain, because website is going to be big and it is better to separate languages technically on different websites, search engines will rank these subdomains more correct.

Please help! This is my first experience with multilingual website and I don't have a clue what to do.

2 Answers 2

1

The problem is the CDN, which connects to Drupal via HTTP and to the client via HTTPS. Then all absolute URLs generated by Drupal have the wrong protocol. Not only this one for ajax, which is absolute because you've switched language detection to domain based. Prefix based it uses relative paths and then the protocol doesn't matter.

Normally CDN's add a header X_FORWARDED_PROTO to the request, which Drupal can use to determine the correct protocol. For this to work you have to configure the CDN as reverse proxy in settings.php.

5
  • I think I'm doing something wrong. In settings.php I've enabled $settings['reverse_proxy'] by setting it ti TRUE and uncommenting the rest: $settings['reverse_proxy_addresses'] (added all known cloudflare's ip addresses), $settings['reverse_proxy_proto_header'] = 'X_FORWARDED_PROTO'; and $settings['omit_vary_cookie'] = TRUE; But stil doesn't work.
    – bigboy
    Commented Oct 26, 2018 at 10:23
  • I've answered to explain how the ajax behavior might be connected to the CDN setup. For the latter see drupal.stackexchange.com/questions/199722/…
    – 4uk4
    Commented Oct 26, 2018 at 11:07
  • I've checked $_SERVER output and it shows, that X_FORWARDED_PROTO is set to http, as well as REQUEST_SCHEME. Enabling or disabling ['reverse_proxy'] in settings.php does nothing.
    – bigboy
    Commented Oct 26, 2018 at 11:10
  • Then this is probably an issue with the CDN configuration to get the correct client protocol into X_FORWARDED_PROTO.
    – 4uk4
    Commented Oct 26, 2018 at 11:12
  • The only place I found https mentioned is here: [HTTP_CF_VISITOR] => {"scheme":"https"}. But I don't think, that I can use this cloudflare header somehow in Drupal. Maybe I need to configure my web server somehow? Because I did nothing in server config.
    – bigboy
    Commented Oct 26, 2018 at 11:31
0

Ok, after hours of searching the web, googling, asking... here is the solution.

1) Go to ISP panel > Web-server settings > SSL Sertificates > add self signed sertificate for your domain.

2) While in ISP, go to WWW-domains and double click on your domain > check Secure connection (SSL), SSL port - 443, select your sertificate from dropdown list and save.

3) Then go to Cloudflare domain settings, open Crypto page and change SSL from Flexible to Full.

Thats it! As simple as that. And there is no need in reverse proxy in settings.php

2
  • Yes, this is best solution, if you can setup a secure connection between CDN and Drupal. Though you might still want to configure the CDN in settings.php to get the correct client IP.
    – 4uk4
    Commented Oct 26, 2018 at 14:24
  • @4k4 I've installed Cloudflare module for this (drupal.org/project/cloudflare)
    – bigboy
    Commented Oct 28, 2018 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.