Use bind mounts for nginx config

This commit is contained in:
Matthew Lopez
2023-12-18 20:44:39 -05:00
parent d745c3b91d
commit afd592b1f2
4 changed files with 57 additions and 1 deletions

View File

@@ -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:

30
config/nginx.conf Normal file
View File

@@ -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;
}

12
config/nginx/account.conf Normal file
View File

@@ -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;
}
}

View File

@@ -0,0 +1,7 @@
server {
listen 80 default_server;
location / {
return 404;
}
}