Cloudflare & SSL

Pre-requisites

  • A registered domain name
  • A Cloudflare account

Cloudflare setup

  • Add your domain to Cloudflare
  • Cloudflare will give you two nameservers
  • Go to your domain registrar and change the nameservers to the ones provided by Cloudflare
  • Wait for the nameservers to propagate
  • Go to Cloudflare and click on SSL/TLS tab
  • Select Full under Overview section
  • Select Edge Certificates tab and enable Always Use HTTPS option
  • Select SSL/TLS tab and enable Automatic HTTPS Rewrites option
  • Select DNS section and add following records:
    • A record with name @ and value your-server-ip
    • A record with name www and value your-server-ip
  • Navigate to Origin Certificates tab and click on Create Certificate
  • Generate a certificate with default settings.
  • Download the certificate and key files.

SSL setup

  • Go to the NPM dashboard and click on SSL Certificates and add the certificate and key files.
  • Visit your domain and you should see the nginx welcome page with a valid SSL certificate.