diff --git a/active/container_nginx/nginx.conf b/active/container_nginx/nginx.conf deleted file mode 100644 index 4266c2a..0000000 --- a/active/container_nginx/nginx.conf +++ /dev/null @@ -1,46 +0,0 @@ -user nginx; -worker_processes auto; - -error_log /var/log/nginx/error.log notice; -pid /var/run/nginx.pid; - -events { - worker_connections 1024; -} - -stream { - log_format stream_logs '$remote_addr [$time_local] $protocol $status $bytes_sent $bytes_received $session_time "$upstream_addr"'; - - access_log /dev/stdout stream_logs; - error_log stderr info; - - server { - listen 3478; - listen [::]:3478; - proxy_pass nextcloud.reeselink.com:3478; - } - - server { - listen 2222; - listen [::]:2222; - proxy_pass gitea.reeselink.com:2222; - } - - server { - listen 8080; - listen [::]:8080; - proxy_pass unifi-external.reeselink.com:2222; - } - - server { - listen 25565; - listen [::]:25565; - proxy_pass minecraft.reeselink.com:25565; - } - - server { - listen 25566; - listen [::]:25566; - proxy_pass minecraft.reeselink.com:25566; - } -} \ No newline at end of file diff --git a/active/container_nginx/nginx.md b/active/container_nginx/nginx.md index 1cb2fde..fa1db37 100644 --- a/active/container_nginx/nginx.md +++ b/active/container_nginx/nginx.md @@ -2,6 +2,35 @@ ## Initial Install +Create your initial `secrets/nginx.conf` to look something like: + +```conf +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +stream { + log_format stream_logs '$remote_addr [$time_local] $protocol $status $bytes_sent $bytes_received $session_time "$upstream_addr"'; + + access_log /dev/stdout stream_logs; + error_log stderr info; + + server { + listen 25565; + listen [::]:25565; + proxy_pass my-minecraft-server.internal.dns:25565; + } +} +``` + +Create the systemd service: + ```bash # Get the initial configuration vim /etc/containers/systemd/nginx.container @@ -26,11 +55,27 @@ Restart=always WantedBy=default.target ``` -## Update the Configuration +Reload the service and start it: ```bash -scp active/container_nginx/nginx.conf proxy:/etc/nginx/nginx.conf -ssh proxy systemctl daemon-reload systemctl start nginx ``` + +## Update the Configuration + +```bash +scp active/container_nginx/secrets/nginx.conf proxy:/etc/nginx/nginx.conf +ssh proxy +systemctl restart nginx +``` + +## Logs + +```bash +# Watch client connections +journalctl -u nginx -f | grep -e 'client .* connected' + +# Watch upstream proxy connections +journalctl -u nginx -f | grep -e 'proxy .* connected' +```