You could add a nginx reverse proxy to your docker-compose file:
reverse:
container_name: reverse
hostname: reverse
image: nginx:latest
ports:
- 80:80
- 443:443
restart: always
volumes:
- ./nginx/conf/:/etc/nginx/conf.d/:ro
titra:
image: kromit/titra
container_name: titra
hostname: titra
depends_on:
- mongodb
environment:
- ROOT_URL=https://timesheet
- MONGO_URL=mongodb://mongodb/titra
- PORT=3000
ports:
- "3000:3000"
restart: always
mongodb:
image: mongo:4.4
container_name: mongodb
hostname: mongodb
restart: always
volumes:
- /srv/mongodb/:/data/db
Your nginx should be configured with a *.conf like containing something like this:
upstream titra {
server titra:3000;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name timesheet;
ssl_certificate /etc/nginx/ssl/live/timesheet/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/timesheet/privkey.pem;
location / {
proxy_pass http://titra;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
I have a similar setup and it works fine. It's based loosely on
https://www.freecodecamp.org/news/docker-nginx-letsencrypt-easy-secure-reverse-proxy-40165ba3aee2/