add nginx service

This commit is contained in:
James 2022-01-31 20:48:54 +00:00
parent cb94c84ea0
commit 2689f177ac
4 changed files with 59 additions and 1 deletions

View File

@ -42,3 +42,17 @@ services:
depends_on:
- db
- redis
nginx:
build: nginx
restart: unless-stopped
ports:
- ${NGINX_HTTP_PORT}:80
- ${NGINX_HTTPS_PORT}:443
volumes:
- ${SSL_CERT_PATH}:/etc/ssl/certs/server.cert.pem
- ${SSL_KEY_PATH}:/etc/ssl/private/server.key.pem
environment:
NGINX_HOST: ${NGINX_HOST}
depends_on:
- nextcloud

9
nginx/Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM nginx:latest
COPY default.conf /tmp/nginx/default.conf
COPY docker-entrypoint.sh /tmp/docker-entrypoint.sh
RUN chmod 755 /tmp/docker-entrypoint.sh
ENTRYPOINT [ "/tmp/docker-entrypoint.sh" ]
CMD ["nginx", "-g", "daemon off;"]

29
nginx/default.conf Normal file
View File

@ -0,0 +1,29 @@
server {
listen 443 ssl;
server_name ${NGINX_HOST};
ssl_certificate /etc/ssl/certs/server.cert.pem;
ssl_certificate_key /etc/ssl/private/server.key.pem;
location / {
proxy_pass http://nextcloud:80;
proxy_headers_hash_max_size 512;
proxy_headers_hash_bucket_size 64;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header Front-End-Https on;
client_max_body_size 1G;
}
}
server {
if ($host = ${NGINX_HOST}) {
return 301 https://$host$request_uri;
}
listen 80;
server_name ${NGINX_HOST};
}

View File

@ -0,0 +1,6 @@
#!/usr/bin/env sh
set -eu
envsubst '${NGINX_HOST}' < /tmp/nginx/default.conf > /etc/nginx/conf.d/default.conf
exec "$@"