Sorry, I know that was quite a mouthful.
Here’s what I’m trying to do in order to get a Cloudflare tunnel to connect from the internet to an application running on a Droplet:
I’m happy to use either the free cert that Cloudflare generates or a dedicated / third-party one which I purchased (whatever gives the least trouble).
If I want to go with the Cloudflare option: I have the certs. I’m just lost and confused as to how to get them into the Nginx container (which I think has to be a container for the app/architecture that it’s part of.)
Any pointers or ways to do this simply?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Hey!
One quick option here would be to setup an Nginx service on the Droplet itself and use Let’s encrypt with certbot for the SSL management:
Then in the Nginx config you can setup a reverse proxy rule to forward the traffic from the Nginx service running on the Droplet on port 443 to the docker container itself.
Alternatively, as you mentioned, setting up Cloudflare edge certificates on a Dockerized Nginx instance running on a Droplet would require a few key steps.
First, you need to have your Cloudflare SSL certificates ready. These usually include:
.pem
file for the certificate itself.key
file for the private keyIf you have chosen to use the free Universal SSL certificate from Cloudflare, you should have these files. If you opt for a dedicated certificate or one purchased from a third party, ensure you have the corresponding files.
After that, you need to modify your Docker configuration to include these certificates and ensure Nginx uses them. Here’s how you can do it:
Step A: Create a Directory for Certificates
On your Droplet, create a directory to store your SSL certificates. This directory will be mounted to the Docker container.
Step B: Update Nginx Configuration
Modify your Nginx configuration file to use the SSL certificates. You can create a new configuration file or edit an existing one.
Make sure to replace
yourdomain.com
,your_certificate.pem
, andyour_private_key.key
with the actual names.Step C: Update Dockerfile or Docker Compose File
To make the certificates available inside the container, you need to mount the directory you created into the Docker container. Here’s an example modification for a Docker Compose file:
Once your Docker container is running with the new configuration, you might need to reload Nginx to apply the changes without stopping the container:
Next, make sure your DNS settings in Cloudflare are set to proxy through Cloudflare. This setting is indicated by an orange cloud icon in your DNS settings. This setup will encrypt the traffic between Cloudflare and your Nginx server using the SSL certificate you installed.
Finally, test your setup to ensure that everything is configured correctly. You can use tools like
curl
or visit your domain in a browser to check the SSL certificate details.Let me know if you have any questions!
Best,
Bobby