Site is down after activating Cloudflare (Certbot-modified Nginx virtual host)


#1

After activating Cloudflare for my domain, I get “The page isn’t redirecting properly” errors for all webpages of the app.

My Nginx logs

There are no errors in the three Nginx logs (nothing that will indicate the source of that problem).

My Nginx confs:

My question

I used Certbot to configure my SSL. What do I need to change in the Certbot-modified virtual host to bring the site back to work?

My assumption

I assume I should change something here (this second sever block created by Certbot seems to me like holding redirections), but I’m not sure what exactly to change here:

server {
    if ($host = www.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    server_name example.com www.example.com;
    listen 80;
    return 404; # managed by Certbot
}

#2

What’s the real name of your site?

In Cloudflare’s control panel, go to the Crypto tab. If the SSL setting is set to “Flexible”, change it to “Full (strict)”.

(Note: That will break subdomains without valid certificates.)


#3

Thanks! It’s judith-law.co.il.

Gladly I usually don’t use any subdomains in my personal projects but it’'s good to know that subdomains usally must have certifications as well.

Please share your thoughts on this, @mnordhoff


#4

They don’t have to have certificates, but Cloudflare’s settings usually apply to all of your subdomains by default.

You can use Page Rules instead, but under the circumstances, I’d encourage you to have valid certificates everywhere if possible.


#5

I usually have everywhere needed - for all domains.


#6

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.