title: HTTPS for docker containers
body: <p>I am developing a workflow service as a training project. Abstracting from the details, everything you need to know for this question is in the <a href="https://i.stack.imgur.com/3KAUt.png" rel="nofollow noreferrer">image</a>. For deployment, I rented a server and ran docker-compose on it. Everything works well, but what I'm worried about is that ports 8000 and 5432 are open.</p>
  <p>The first question is, is it worth worrying? And if so, how to get rid of it?
  Docker-compose file content below</p>
  <pre><code>version: &quot;3&quot;
  
  services:
    db:
      container_name: 'emkk-db'
      image: postgres
      volumes:
        - ./backend/data:/var/lib/postgresql/data
      env_file:
        - ./backend/db.env
      ports:
      - &quot;5432:5432&quot;
  
    backend:
      container_name: 'emkk-backend'
      image: emkk_backend
      build: ./backend
      volumes:
        - ./backend:/emkk/backend
      env_file:
        - ./backend/.env
      ports:
        - &quot;8000:8000&quot;
      depends_on:
        - db
  
    frontend:
      container_name: 'emkk-frontend'
      image: emkk_frontend
      build: ./frontend
      command: npm run start
      env_file:
        - ./frontend/.env
      volumes:
        - /emkk/frontend/node_modules
        - ./frontend:/emkk/frontend
      ports:
        - &quot;80:80&quot;
      depends_on:
        - backend
  </code></pre>
  <p>I also want to configure HTTPS protocol. I tried installing nginx and putting a certificate on it using a certbot, and then proxying requests to containers. I sat with this for several hours and I still did not manage to achieve anything better than a HTTPS for the nginx start page.</p>
  <p>Maybe I'm doing completely wrong things, but I'm new to this, I haven't had to deal with deployments before. I would be grateful for your answers, which will contain an idea or an example of how you can do this.</p>