CloudFlare - Nginx

Hi, the site worked for a month and after a month it only throws: 400 Bad Request - The SSL certificate error…

server {

        server_name my.domain.com;

        location / {
                    proxy_pass http://IP_ADRESS:PORT/;
       }



    listen 443 ssl;
    ssl_certificate /home/api-ssl/cert.pem;
    ssl_certificate_key /home/api-ssl/key.pem;
    ssl_client_certificate /home/api-ssl/cloudflare.crt;
    ssl_verify_client on;

}
server {
    if ($host = my.domain.com) {
        return 301 https://$host$request_uri;
    }



        server_name my.domain.com;
    listen 80;
    return 404;


}

Screenshots: Imgur: The magic of the Internet
Do you know what the problem is? Thank you

Try turning Authenticated Origin Pulls on.
https://developers.cloudflare.com/ssl/origin-configuration/authenticated-origin-pull

1 Like

I’ve had that for a long time, screenshot: Imgur: The magic of the Internet

And I don’t know why, but today it shows this: Imgur: The magic of the Internet
After a while it redirects me to Nginx (400 Bad Request The SSL certificate error)

Is there a reason you need to listen on :80 for this host? The reason I ask is i suspect all your traffic is coming on SSL/443 already, meaning you are causing a redirect loop that will end after 16 (IIRC) and show you the ‘too_many_redirects’ error.

Try removing all of this:

server {
    if ($host = my.domain.com) {
        return 301 https://$host$request_uri;
    }

        server_name my.domain.com;
    listen 80;
    return 404;


}

I removed it, now it looks like this:

server {

        server_name my.domain.com;

        location / {
                    proxy_pass http://my_ip:port/;
       }



    listen 443 ssl;
    ssl_certificate /home/api-ssl/cert.pem;
    ssl_certificate_key /home/api-ssl/key.pem;
    ssl_client_certificate /home/api-ssl/cloudflare.crt;
    ssl_verify_client on;

}

I keep getting a 400 error :frowning:

Solved, I used the wrong Cloudflare certificate … :DD