Question

Securing Dockerized MERN app via HTTPS?

I am building a MERN stack application in docker containers, deployed with docker-compose, as a personal project, which i will deploy. i am curious how i go about securing this.

i know that i need to setup https between the client and my backend(api), and have seen several examples where they set up an nginx server in the frontend(react app) container. how does this nginx server differentiate requests to the api (logging in/fetching sensitive data) and requests for the webpage iteself.

the terms load-balancer and reverse proxy come up alot.

is it possible to set up a digital ocean load balancer with https proxying which points to my droplet on my vpc?

i’m very new to this, but very interested in learning all i can, thanks for any help!


Submit an answer


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!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
September 6, 2020
Accepted Answer

Hi there,

Yes indeed, using a Managed Load Balancer and doing your SSL termination there sounds like a good setup. This would also allow you to scale up your application in the future if needed.

Another thing you could do is have an Nginx container on your Droplet with Let’s Encrypt. You can actually follow the steps from this tutorial on how to set up the Nginx part:

https://www.digitalocean.com/community/tutorials/how-to-secure-a-containerized-node-js-application-with-nginx-let-s-encrypt-and-docker-compose

The tutorial will show you how to do this for NodeJS but the Nginx part should be quite similar despite the backed.

Regards, Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.