diff --git a/.env.example b/.env.example index 0ad8a8c..8091795 100644 --- a/.env.example +++ b/.env.example @@ -21,3 +21,8 @@ SMTP_DOMAIN="domain.com" SMTP_PORT=465 SMTP_FROM="Company CO" SMTP_EMAIL="domain@domain.com" + +# NGINX +SERVER_NAME=tryton.domain.com +NGINX_PORT=10000 +VARIABLE=$ diff --git a/docker-compose.yaml b/docker-compose.yaml index 110adde..e2fe1cf 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -26,8 +26,6 @@ services: TRYTOND_DATABASE_URI: ${TRYTOND_DATABASE_URI:-postgresql://${POSTGRES_USER:-naliia}:${POSTGRES_PASSWORD:-SUp3r-pass*DB}@${DB_HOSTNAME:-db}:5432/} NALIIA_IMAGE: ${NALIIA_IMAGE:-gitea.onecluster.org/aserrador/naliia:latest} EMAIL: ${EMAIL:-admin@admin.org} - ports: - - "${TRYTON_PORT:-8000}:8000" depends_on: db: condition: service_healthy @@ -71,6 +69,18 @@ services: TRYTOND_DATABASE_URI: ${TRYTOND_DATABASE_URI:-postgresql://${POSTGRES_USER:-naliia}:${POSTGRES_PASSWORD:-SUp3r-pass*DB}@${DB_HOSTNAME:-db}:5432/} env_file: - .env + nginx: + image: nginx:1.23.3 + volumes: + - ./nginx.conf:/etc/nginx/conf.d/nginx.conf.template + ports: + - "${NGINX_PORT:-10000}:${NGINX_PORT:-10000}" + env_file: + - .env + depends_on: + - tryton + - db + command: /bin/bash -c "envsubst < /etc/nginx/conf.d/nginx.conf.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" volumes: postgres: diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..7d15661 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,19 @@ +server { + server_name ${SERVER_NAME}; + listen ${NGINX_PORT}; + client_max_body_size 8M; + + sendfile on; + send_timeout 500s; + + location / { + proxy_pass http://tryton:8000/; # "trytond" is the service name of another Docker container on port 8000 + proxy_read_timeout 500; + proxy_connect_timeout 500; + proxy_send_timeout 500; + proxy_set_header Host ${VARIABLE}host; + proxy_set_header X-Real-IP ${VARIABLE}remote_addr; + proxy_set_header X-Forwarded-For ${VARIABLE}proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host ${VARIABLE}server_name; + } +}