SSL in Dockerfile I just dont get it

Hello! My hoster is only accepting Docker images. It will map any port to :40xxx. I can access my flask app on http.
Last hoster I just used nginx with cert.pem and key.pem. I tried to include nginx into Dockerfile but only got default startpage even
services:
nginx:
volumes: -./nginx.conf:/etc/ngvinx/nginx.conf

but its in docker-compose.yml and it seems not to be included in docker build images. So I tried using gunicorn for reverse proxy which returns something like SSL_INSECURE and can't the mapped :40xxx port in https but works in http

What is the best approach? Hoster options are limited, my knowledge too... I tried some tutorials but can not get SSL working. If I choose Hoster SSH options, I can connect with PuTTY but I don't get a public IP to access. Other option is using Docker Repo

I don't understand how to implement the docker-compose yml when I can only use 1 Docker image or how to include certbot into the docker image. Do I have to create a run.sh to run certbot and then start gunicorn? Since every port (:443) is mapped to a :40xxx port can I even use SSL on the mapped port?

Sorry it's very beginner questions. I tried to google but didn't find a solution. Hope you can help me understand.

My domain is: vast ai

I ran this command: sudo certbot certonly -d domain.com -n --standalone with docker options CMD ["python3", "-m", "gunicorn", "-w", "4", "-b", 0.0.0.0:5000", "--certfile", "/etc/letsencrypt/live/domain.com/fullchain.pem","--keyfile","/etc/letsencrypt/live/domain.com/privkey.pem","app:app","--timeout","120"] . also tried services: certbot: image: certbot/certbot in Dockerfile

It produced this output: SSL_INSECURE, only http:// working

My web server is (include version): gunicorn, nginx

The operating system my web server runs on is (include version): python:3.7-slim

My hosting provider, if applicable, is: vast ai

I can login to a root shell on my machine (yes or no, or I don't know): no

I'm using a control panel to manage my site: no

The version of my client is: 2.11.0

My first suggestion is that if this hosting company doesn't offer the services you need then look at other hosting companies or options.

If they have such strict restrictions it seems to me they should offer suggestions on how to resolve common concerns. Being able to support HTTPS these days is a basic requirement (pretty much).

It seems like most of your questions are how to setup docker at that hosting company. Maybe try a docker forum. Or a support forum for that hoster.

I am no docker expert so cannot offer anything more.

3 Likes

Maybe this helps ... if you have a Certbot container mapped to receive HTTP (port 80) requests on, for example, port 40080, you could try this:

sudo certbot certonly --standalone --http-01-port 40080 -d example.com -n

As for coordinating your containers and sharing the volumes I can't help.

From the Certbot docs:

--http-01-port HTTP01_PORT
Port used in the http-01 challenge. This only affects
the port Certbot listens on. A conforming ACME server
will still attempt to connect on port 80. (default: 80)

2 Likes

AWS Lightsail is $3.50 per month for your own linux VM.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.