Skip to content

Commit

Permalink
Merge pull request #246 from Integral-Tech/add-nginx-certbot
Browse files Browse the repository at this point in the history
Add nginx certbot examples
  • Loading branch information
clansty authored Oct 7, 2024
2 parents 4771eaa + ce5811c commit ad3fc28
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
volumes:
- postgresql:/var/lib/postgresql/data

tunnel: #如果没有使用 Cloudflare Tunnel 暴露内网端口,可以删除这一小节
tunnel:
container_name: cloudflared-tunnel
image: cloudflare/cloudflared
restart: unless-stopped
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
version: "3.8"

volumes:
postgresql:
q2tg:
cache:
napcat-data:
napcat-config:

services:
postgres:
image: postgres:14-alpine
restart: unless-stopped
environment:
POSTGRES_DB: db_name
POSTGRES_USER: user
POSTGRES_PASSWORD: password
volumes:
- postgresql:/var/lib/postgresql/data

napcat:
image: mlikiowa/napcat-docker:latest
environment:
- ACCOUNT=要登录的 QQ 号
- WS_ENABLE=true
- NAPCAT_GID=1000
- NAPCAT_UID=1000
ports:
- 6099:6099
mac_address: 02:42:12:34:56:78 # 请修改为一个固定的 MAC 地址,但是不要和其他容器或你的主机重复
restart: unless-stopped
volumes:
- napcat-data:/app/.config/QQ
- napcat-config:/app/napcat/config
- cache:/app/.config/QQ/NapCat/temp

q2tg:
image: ghcr.io/clansty/q2tg:sleepyfox
restart: unless-stopped
depends_on:
- postgres
- napcat
ports:
# 如果要使用 RICH_HEADER 需要将端口发布到公网
- 8080:8080
volumes:
- q2tg:/app/data
- cache:/app/.config/QQ/NapCat/temp
- /var/run/docker.sock:/var/run/docker.sock
environment:
- TG_API_ID=
- TG_API_HASH=
- TG_BOT_TOKEN=
- DATABASE_URL=postgres://user:password@postgres/db_name
- NAPCAT_WS_URL=ws://napcat:3001
- TG_CONNECTION=tcp # 连接 Telegram 的方式,也可以改成 websocket
# 如果你需要使用 /flags set RICH_HEADER 来显示头像,或者正确显示合并转发的消息记录,则需将 q2tg 8080 端口发布到公网,可以使用 cloudflare tunnel
# 请尽量配置这个服务
- WEB_ENDPOINT= # https://yourichheader.com 填写你发布到公网的域名
#- CRV_VIEWER_APP=
# DEPRECATED: 请使用 WEB_ENDPOINT
#- CRV_API=
#- CRV_KEY=
# 要关闭文件上传提示,请取消注释以下变量 https://github.com/clansty/Q2TG/issues/153
#- DISABLE_FILE_UPLOAD_TIP=1
# 如果需要通过代理联网,那么设置下面两个变量
#- PROXY_IP=
#- PROXY_PORT=
# 代理联网认证,有需要请修改下面两个变量
#- PROXY_USERNAME=
#- PROXY_PASSWORD=

nginx:
image: nginx:alpine
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./certbot/www:/var/www/certbot:ro
- ./certbot/cert:/etc/letsencrypt:ro
depends_on:
- q2tg

certbot:
image: certbot/certbot:latest
volumes:
- ./certbot/www:/var/www/certbot
- ./certbot/cert:/etc/letsencrypt
depends_on:
- nginx
command: certonly --webroot -w /var/www/certbot --force-renewal --email 你的邮箱 -d 你的域名 --agree-tos
32 changes: 32 additions & 0 deletions docker-compose-examples/NapCat/with-nginx-certbot/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
worker_processes auto;

events {
worker_connections 1024;
}

http {
server {
listen 80;
listen [::]:80;

location /.well-known/acme-challenge/ {
root /var/www/certbot;
}

location / {
return 301 https://$host$request_uri;
}
}

# server {
# listen 443 ssl;
# listen [::]:443 ssl;
# server_name 你的域名;
# ssl_certificate /etc/letsencrypt/live/你的域名/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/你的域名/privkey.pem;

# location / {
# proxy_pass http://q2tg:8080;
# }
# }
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
volumes:
- postgresql:/var/lib/postgresql/data

tunnel: #如果没有使用 Cloudflare Tunnel 暴露内网端口,可以删除这一小节
tunnel:
container_name: cloudflared-tunnel
image: cloudflare/cloudflared
restart: unless-stopped
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
version: "3.8"

volumes:
postgresql:
q2tg:
cache:

services:
# 如果有现成的 Postgresql 实例,可以删除这一小节
postgres:
image: postgres:14-alpine
restart: unless-stopped
environment:
POSTGRES_DB: db_name
POSTGRES_USER: user
POSTGRES_PASSWORD: password
volumes:
- postgresql:/var/lib/postgresql/data

sign:
image: ghcr.io/clansty/qsign
restart: unless-stopped

q2tg:
image: ghcr.io/clansty/q2tg:sleepyfox
restart: unless-stopped
depends_on:
- postgres
- sign
ports:
# 如果要使用 RICH_HEADER 需要将端口发布到公网
- 8080:8080
volumes:
- q2tg:/app/data
# 下面这行是固定的,和你用不用 NapCat 没关系,不要动
- cache:/app/.config/QQ/NapCat/temp
- /var/run/docker.sock:/var/run/docker.sock
environment:
- TG_API_ID=
- TG_API_HASH=
- TG_BOT_TOKEN=
- DATABASE_URL=postgres://user:password@postgres/db_name
- SIGN_API=http://sign:4848/sign?key=114514
- SIGN_VER=9.0.56 # 与上方 sign 容器的配置同步
- TG_CONNECTION=tcp # 连接 Telegram 的方式,也可以改成 websocket
# 如果你需要使用 /flags set RICH_HEADER 来显示头像,或者正确显示合并转发的消息记录,则需将 q2tg 8080 端口发布到公网,可以使用 cloudflare tunnel
# 请尽量配置这个服务
- WEB_ENDPOINT= # https://yourichheader.com 填写你发布到公网的域名
#- CRV_VIEWER_APP=
# DEPRECATED: 请使用 WEB_ENDPOINT
#- CRV_API=
#- CRV_KEY=
# 要关闭文件上传提示,请取消注释以下变量 https://github.com/clansty/Q2TG/issues/153
#- DISABLE_FILE_UPLOAD_TIP=1
# 如果需要通过代理联网,那么设置下面两个变量
#- PROXY_IP=
#- PROXY_PORT=
# 代理联网认证,有需要请修改下面两个变量
#- PROXY_USERNAME=
#- PROXY_PASSWORD=

nginx:
image: nginx:alpine
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./certbot/www:/var/www/certbot:ro
- ./certbot/cert:/etc/letsencrypt:ro
depends_on:
- q2tg

certbot:
image: certbot/certbot:latest
volumes:
- ./certbot/www:/var/www/certbot
- ./certbot/cert:/etc/letsencrypt
depends_on:
- nginx
command: certonly --webroot -w /var/www/certbot --force-renewal --email 你的邮箱 -d 你的域名 --agree-tos
32 changes: 32 additions & 0 deletions docker-compose-examples/icqq/with-nginx-certbot/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
worker_processes auto;

events {
worker_connections 1024;
}

http {
server {
listen 80;
listen [::]:80;

location /.well-known/acme-challenge/ {
root /var/www/certbot;
}

location / {
return 301 https://$host$request_uri;
}
}

# server {
# listen 443 ssl;
# listen [::]:443 ssl;
# server_name 你的域名;
# ssl_certificate /etc/letsencrypt/live/你的域名/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/你的域名/privkey.pem;

# location / {
# proxy_pass http://q2tg:8080;
# }
# }
}

0 comments on commit ad3fc28

Please sign in to comment.