Behind cloudflare - always get 302 for home page and 404 for any other pages

Hi,

This is the first time I try GRAV. My first deployment is as following:

  • Package everything in a docker image. I use the official grav docker: https://github.com/getgrav/docker-grav
  • Deploy a docker container in a docker hosting platform. I use Arukas.io
  • Put a cloudflare in front of my GRAV container

Everything works well on local test. It also works very well on arukas when accessing the website directly via arukas’s URL: for example https://example.arukascloud.io (SSL)

But when I put the cloudflare CDN in front of it follow this guide https://support.arukas.io/hc/en-us/articles/360000844008-How-can-I-set-a-custom-domain-name (I need a custom domain name), when accessing my site via my custom domain name, for example https://www.example.com (also SSL). I got the following weird behaviors:

  • Accessing the home (root) page, always get redirection: https://www.example.com/https,%20https:/www.example.com
    In the stdout of the docker container, I see the following apache log:

    instance #0 | 163.43.82.139 - - [05/Aug/2019:02:08:02 +0000] “GET / HTTP/1.1” 302 686 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36”
    instance #0 | 163.43.82.135 - - [05/Aug/2019:02:08:02 +0000] “GET /https,%20https:/www.example.com HTTP/1.1” 404 7647 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36”
    i

  • Accessing any other pages, always get 404. For example https://www.example.com/about In the apache log, I see:

instance #0 | 163.43.82.138 - - [05/Aug/2019:02:15:45 +0000] "GET /about HTTP/1.1" 404 7647 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"

Anybody knows what could be the cause?

I notice a difference between accessing from cloudflare and accessing via arukas: when being from cloudflare, the referrer is empty ("-").

Bao

I configured apache to dump all request details. Comparing 2 requests, below is the difference (identical info was removed)

Direct request
X-Forwarded-Proto:https
X-Forwarded-For:171.226.224.26

Via Cloudflare
X-Forwarded-For:2402%3a800%3a63b9%3a8d8c%3a48ce%3af6cb%3ab767%3ab23e, 162.158.118.149
X-Forwarded-Proto:https, https
X-Forwarded-Port:443
CF-IPCountry:VN
CF-RAY:50406c355832a5e8-NRT
CF-Visitor:{“scheme”%3a"https"}
cookie:__cfduid=d672b66a6693df320103a05ac21d84a531564917507; grav-site-40d1b2d=ae32ce67611f760a938e65c98b930612
CF-Connecting-IP:2402%3a800%3a63b9%3a8d8c%3a48ce%3af6cb%3ab767%3ab23e|
CDN-Loop:cloudflare

Do these request headers cause the issue?