which of the two files is for ssl and how does it work with cloudflare

Posted July 17, 2019 2.2k views

I created a droplet2 to host from a snapshot image copied from another droplet1 that hosted has wordpress and it works fine, but when I visited , it says too many re-direct.

I have modified droplet2 in this way:

  1. in the /etc/nginx/sites-enabled/default I have replaced domain1 with domain2.

  2. in the /etc/nginx/sites-enabled/default I see this line:

sslcertificate /etc/nginx/ssl/domain2/cert.pem; 
sslcertificatekey /etc/nginx/ssl/domain2/key.pem; 

I have a couple of questions:

2a I see two location for the ssl

location1: the first is this /etc/nginx/ssl/domain2/cert.pem in file /etc/nginx/sites-enabled/default

location2: the second is this one in /etc/nginx/snippets/snakeoil.conf:

 sslcertificate /etc/ssl/certs/ssl-cert-snakeoil.pem; 
 sslcertificatekey /etc/ssl/private/ssl-cert-snakeoil.key;

my question is which location (location1 or location2) can I find my ssl file?

2b I copied the “Origin Certificates” from cloudflare to both /etc/nginx/ssl/domain2/ and /etc/ssl/ but I still have the “too many redirect messages”

3 I noticed that my cloudflare, under Crypto it is “flexible” ssl. When I changed from “flexible” to “full” it seems working, regardless if I used the ssl files downloaded from cloudflare or not. Even if the “Origin Certificates” from cloudflare do not match the files in location1 or locatin2, it is still working with “full” ssl. How is this possible?

edited by MattIPv4

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


The .pem file should be the one you need as it contains all of the necessary SSL files: the private key, the certificate and the CA bundle.

Have you tried checking if the SSL certificate is installed correctly with the website for example or with the openssl command?

Maybe the problem is not with the certificate but with your application itself, for example if you are using Wordpress you need to make sure that your Site and Home URLs are updated correctly, or if you are using Laravel you have to update your APP URL in your env file.

If this was a SSL problem, then you would, in most cases, just get a SSL warning.

Hope that this helps!

  • my 3 questions are:
    question 1: does location1 contain the .pem file or does location2 has it?
    question 2: the cloudflare “flexible” ssl did not work, but “full” worked, why?
    question 3: for the “full” ssl, the .gem did not match, but it worked, why?

    • Hi,

      The questions could be summarized in 1:

      The best way to do it is to have 1 .pem file with all of the SSL files in there. The correct order would be:

      The Private Key
      The Primary Certificate
      The CA bundle

      Then you could use this file and you would make sure that the certificate matches the key.

      Note that the order is really important, otherwise it would not work.