![如何让 Titra docker 镜像回答 https?](https://linux22.com/image/772422/%E5%A6%82%E4%BD%95%E8%AE%A9%20Titra%20docker%20%E9%95%9C%E5%83%8F%E5%9B%9E%E7%AD%94%20https%EF%BC%9F.png)
我有一个测试安装蒂特拉在本地系统上,我使用这个 docker-compose 文件在端口 80 上应答 http:
version: "2.0"
services:
titra:
image: kromit/titra
container_name: titra
depends_on:
- mongodb
environment:
- ROOT_URL=http://timesheet
- MONGO_URL=mongodb://mongodb/titra
- PORT=3000
ports:
- "80:3000"
restart: always
mongodb:
image: mongo:4.4
container_name: mongodb
restart: always
volumes:
- /root/titradb:/data/db
这可行,但我有点喜欢回答 https 的东西,但我不太熟悉蒂特拉本身也不流星(它所编写的框架),并且我查阅了可用的文档,但没有找到有关自托管 Titra 实例的 https 的任何信息。
答案1
您可以将 nginx 反向代理添加到您的 docker-compose 文件:
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
你的 nginx 应该配置一个 *.conf,其中包含如下内容: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;
}
}
我有一个类似的设置,它工作得很好。它大致基于
https://www.freecodecamp.org/news/docker-nginx-letsencrypt-easy-secure-reverse-proxy-40165ba3aee2/