From afd592b1f2b9d2117182bbb31cec7d1141a98378 Mon Sep 17 00:00:00 2001 From: Matthew Lopez <73856503+MatthewL246@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:44:39 -0500 Subject: [PATCH] Use bind mounts for nginx config --- compose.yml | 9 ++++++++- config/nginx.conf | 30 ++++++++++++++++++++++++++++++ config/nginx/account.conf | 12 ++++++++++++ config/nginx/default.conf | 7 +++++++ 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 config/nginx.conf create mode 100644 config/nginx/account.conf create mode 100644 config/nginx/default.conf diff --git a/compose.yml b/compose.yml index 4d0e928..891a2a3 100644 --- a/compose.yml +++ b/compose.yml @@ -31,10 +31,17 @@ services: command: -conf /etc/coredns/Corefile nginx: - build: ./nginx + image: nginx:mainline-alpine ports: - 80:80 - 443:443 + volumes: + - type: bind + source: ./config/nginx.conf + target: /etc/nginx/nginx.conf + - type: bind + source: ./config/nginx + target: /etc/nginx/conf.d/ dns: 172.20.0.2 networks: default: diff --git a/config/nginx.conf b/config/nginx.conf new file mode 100644 index 0000000..89561bf --- /dev/null +++ b/config/nginx.conf @@ -0,0 +1,30 @@ +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + + keepalive_timeout 65; + + resolver 127.0.0.11 valid=600s; + + include /etc/nginx/conf.d/*.conf; +} diff --git a/config/nginx/account.conf b/config/nginx/account.conf new file mode 100644 index 0000000..f30c05b --- /dev/null +++ b/config/nginx/account.conf @@ -0,0 +1,12 @@ +server { + listen 80; + server_name account.pretendo.cc c.account.pretendo.cc conntest.pretendo.cc + nasc.pretendo.cc datastore.pretendo.cc api.pretendo.cc assets.pretendo.cc; + + # This prevents nginx from exiting on startup if it can't resolve the upstream + set $upstream http://account:8080; + location / { + proxy_pass $upstream; + proxy_set_header Host $host; + } +} diff --git a/config/nginx/default.conf b/config/nginx/default.conf new file mode 100644 index 0000000..d127cc5 --- /dev/null +++ b/config/nginx/default.conf @@ -0,0 +1,7 @@ +server { + listen 80 default_server; + + location / { + return 404; + } +}