feat: support proxying

This commit is contained in:
decentral1se 2021-12-08 15:50:30 +01:00
parent 8ea9f28379
commit f28ffa3aaf
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
3 changed files with 57 additions and 16 deletions

View File

@ -1 +1,2 @@
export APP_ENTRYPOINT_VERSION=v1
export NGINX_CONFIG_VERSION=v1

View File

@ -2,6 +2,27 @@
version: "3.8"
services:
web:
image: nginx:1.20.0
networks:
- proxy
- internal
environment:
- DOMAIN
- STACK_NAME
configs:
- source: nginx_config
target: /etc/nginx/nginx.conf
deploy:
restart_policy:
condition: on-failure
labels:
- "traefik.enable=true"
- "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=80"
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`)"
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
app:
image: "lscr.io/linuxserver/calibre-web:0.6.14"
environment:
@ -15,28 +36,14 @@ services:
- config:/config
- books:/books
networks:
- proxy
- internal
configs:
- source: app_entrypoint
target: /config/custom-cont-init.d/entrypoint.sh
mode: 0555
deploy:
restart_policy:
condition: on-failure
labels:
- "traefik.enable=true"
- "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=8083"
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`)"
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8083"]
interval: 30s
timeout: 10s
retries: 10
start_period: 1m
networks:
internal:
proxy:
external: true
@ -49,3 +56,7 @@ configs:
name: ${STACK_NAME}_app_entrypoint_${APP_ENTRYPOINT_VERSION}
file: entrypoint.sh.tmpl
template_driver: golang
nginx_config:
name: ${STACK_NAME}_nginx_config_${NGINX_CONFIG_VERSION}
file: nginx.conf.tmpl
template_driver: golang

29
nginx.conf.tmpl Normal file
View File

@ -0,0 +1,29 @@
user www-data;
events {
worker_connections 768;
}
http {
upstream backend {
server {{ env "STACK_NAME" }}_app:8083;
}
include /etc/nginx/mime.types;
server {
listen 80;
server_name {{ env "DOMAIN" }};
client_max_body_size 20M;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme https;
proxy_pass http://backend;
}
}
}