'Nginx Docker how to set up SSL cert on AWS

I have been trying for days to deploy my containerized PERN stack app on AWS ec2 instance, and expose the api port 5000 through https.

I set up a thing called Swag https://docs.linuxserver.io/general/swag to handle the reverse-proxy and ssl certs. However, I cannot get it to work so it creates a reverse proxy to my other container.

So far the app is running fine with http on EC2 with a custom subdomain.mydomain.com I also managed to get https to work on ports 80 and 443.

The problem is the node container (called api in docker-compose.yml) is not using https. It is exposed on port 5000, and it only works with http://subdomain.mydomain.com:5000

The swag docs do not cover my use case. I would have thought this is a very common thing to need https with an api on aws, whilst using docker. Does anybody have any idea how to go about it? Or do I just have to undockerize my app?

Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source