From 2f96a5912042cc9e3bb944521e496b1ddc290d75 Mon Sep 17 00:00:00 2001 From: Florens Pauwels Date: Sat, 25 Jun 2022 11:39:26 +0200 Subject: [PATCH 1/4] Dockerize --- .dockerignore | 7 +++++++ Dockerfile | 9 +++++++++ docker-compose.yml | 12 ++++++++++++ tools/apache-hosts/Dockerfile | 10 ++++++++++ 4 files changed, 38 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 tools/apache-hosts/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cbd92ee --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.dockerignore +.git +.gitattributes +.github +.gitignore +Dockerfile +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3a74afd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:2-alpine + +RUN apk add --no-cache musl-dev gcc +RUN pip install twisted + +COPY . /app +WORKDIR /app + +ENTRYPOINT ["python", "master_server.py"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a4d47b9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3' + +services: + backend: + build: + context: . + network_mode: "host" + + proxy: + build: + context: tools/apache-hosts + network_mode: "host" diff --git a/tools/apache-hosts/Dockerfile b/tools/apache-hosts/Dockerfile new file mode 100644 index 0000000..fcb9f09 --- /dev/null +++ b/tools/apache-hosts/Dockerfile @@ -0,0 +1,10 @@ +FROM httpd:2.4-alpine + +ENV APACHE_LOG_DIR=/usr/local/apache2/logs + +# TODO: do in one line +RUN echo "IncludeOptional /usr/local/apache2/vhost.d/*.conf" >> conf/httpd.conf +RUN sed -i 's/^#LoadModule proxy_module/LoadModule proxy_module/' conf/httpd.conf +RUN sed -i 's/^#LoadModule proxy_http_module/LoadModule proxy_http_module/' conf/httpd.conf + +COPY *.conf vhost.d/ From 10c071164535658eceeb3f8c9750f704f02bad93 Mon Sep 17 00:00:00 2001 From: Florens Pauwels Date: Sat, 25 Jun 2022 13:54:06 +0200 Subject: [PATCH 2/4] Extra options in httpd.conf --- tools/apache-hosts/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/apache-hosts/Dockerfile b/tools/apache-hosts/Dockerfile index fcb9f09..7b82796 100644 --- a/tools/apache-hosts/Dockerfile +++ b/tools/apache-hosts/Dockerfile @@ -3,7 +3,9 @@ FROM httpd:2.4-alpine ENV APACHE_LOG_DIR=/usr/local/apache2/logs # TODO: do in one line -RUN echo "IncludeOptional /usr/local/apache2/vhost.d/*.conf" >> conf/httpd.conf +RUN echo $'IncludeOptional /usr/local/apache2/vhost.d/*.conf\n\ +ServerName localhost\n\ +HttpProtocolOptions Unsafe' >> conf/httpd.conf RUN sed -i 's/^#LoadModule proxy_module/LoadModule proxy_module/' conf/httpd.conf RUN sed -i 's/^#LoadModule proxy_http_module/LoadModule proxy_http_module/' conf/httpd.conf From efb7ca1b8031773dce965830ea64532f78502c2b Mon Sep 17 00:00:00 2001 From: Florens Pauwels Date: Sat, 25 Jun 2022 15:03:19 +0200 Subject: [PATCH 3/4] Allow specifying a host for a custom domain --- docker-compose.yml | 2 ++ tools/apache-hosts/Dockerfile | 4 ++++ tools/apache-hosts/dls1.nintendowifi.net.conf | 6 +++--- .../apache-hosts/gamestats.gs.nintendowifi.net.conf | 4 ++-- .../apache-hosts/gamestats2.gs.nintendowifi.net.conf | 4 ++-- .../nas-naswii-conntest.nintendowifi.net.conf | 12 ++++++------ tools/apache-hosts/sake.gs.nintendowifi.net.conf | 8 ++++---- 7 files changed, 23 insertions(+), 17 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a4d47b9..d5c8854 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,4 +9,6 @@ services: proxy: build: context: tools/apache-hosts +# environment: +# - HOST=example.com network_mode: "host" diff --git a/tools/apache-hosts/Dockerfile b/tools/apache-hosts/Dockerfile index 7b82796..0083e6a 100644 --- a/tools/apache-hosts/Dockerfile +++ b/tools/apache-hosts/Dockerfile @@ -2,6 +2,10 @@ FROM httpd:2.4-alpine ENV APACHE_LOG_DIR=/usr/local/apache2/logs +# Change this if you have your own domain name set up +# Otherwise, you will need to set up a DNS server to point nintendowifi.net to your IP address +ENV HOST=nintendowifi.net + # TODO: do in one line RUN echo $'IncludeOptional /usr/local/apache2/vhost.d/*.conf\n\ ServerName localhost\n\ diff --git a/tools/apache-hosts/dls1.nintendowifi.net.conf b/tools/apache-hosts/dls1.nintendowifi.net.conf index fda65ea..1b46827 100644 --- a/tools/apache-hosts/dls1.nintendowifi.net.conf +++ b/tools/apache-hosts/dls1.nintendowifi.net.conf @@ -1,8 +1,8 @@ ServerAdmin webmaster@localhost - ServerName dls1.nintendowifi.net - ServerAlias "dls1.nintendowifi.net" - ServerAlias "dls1.nintendowifi.net, dls1.nintendowifi.net" + ServerName dls1.${HOST} + ServerAlias "dls1.${HOST}" + ServerAlias "dls1.${HOST}, dls1.${HOST}" ProxyPreserveHost On ProxyPass / http://127.0.0.1:9003/ ProxyPassReverse / http://127.0.0.1:9003/ diff --git a/tools/apache-hosts/gamestats.gs.nintendowifi.net.conf b/tools/apache-hosts/gamestats.gs.nintendowifi.net.conf index dc67950..df9a761 100644 --- a/tools/apache-hosts/gamestats.gs.nintendowifi.net.conf +++ b/tools/apache-hosts/gamestats.gs.nintendowifi.net.conf @@ -1,7 +1,7 @@ ServerAdmin webmaster@localhost - ServerName gamestats.gs.nintendowifi.net - ServerAlias "gamestats.gs.nintendowifi.net, gamestats.gs.nintendowifi.net" + ServerName gamestats.gs.${HOST} + ServerAlias "gamestats.gs.${HOST}, gamestats.gs.${HOST}" ProxyPreserveHost On ProxyPass / http://127.0.0.1:9002/ ProxyPassReverse / http://127.0.0.1:9002/ diff --git a/tools/apache-hosts/gamestats2.gs.nintendowifi.net.conf b/tools/apache-hosts/gamestats2.gs.nintendowifi.net.conf index 3f79350..21da7b9 100644 --- a/tools/apache-hosts/gamestats2.gs.nintendowifi.net.conf +++ b/tools/apache-hosts/gamestats2.gs.nintendowifi.net.conf @@ -1,7 +1,7 @@ ServerAdmin webmaster@localhost - ServerName gamestats2.gs.nintendowifi.net - ServerAlias "gamestats2.gs.nintendowifi.net, gamestats2.gs.nintendowifi.net" + ServerName gamestats2.gs.${HOST} + ServerAlias "gamestats2.gs.${HOST}, gamestats2.gs.${HOST}" ProxyPreserveHost On diff --git a/tools/apache-hosts/nas-naswii-conntest.nintendowifi.net.conf b/tools/apache-hosts/nas-naswii-conntest.nintendowifi.net.conf index 94da24c..68fe032 100644 --- a/tools/apache-hosts/nas-naswii-conntest.nintendowifi.net.conf +++ b/tools/apache-hosts/nas-naswii-conntest.nintendowifi.net.conf @@ -1,11 +1,11 @@ ServerAdmin webmaster@localhost - ServerName naswii.nintendowifi.net - ServerAlias "naswii.nintendowifi.net, naswii.nintendowifi.net" - ServerAlias "nas.nintendowifi.net" - ServerAlias "nas.nintendowifi.net, nas.nintendowifi.net" - ServerAlias "conntest.nintendowifi.net" - ServerAlias "conntest.nintendowifi.net, conntest.nintendowifi.net" + ServerName naswii.${HOST} + ServerAlias "naswii.${HOST}, naswii.${HOST}" + ServerAlias "nas.${HOST}" + ServerAlias "nas.${HOST}, nas.${HOST}" + ServerAlias "conntest.${HOST}" + ServerAlias "conntest.${HOST}, conntest.${HOST}" ProxyPreserveHost On ProxyPass / http://127.0.0.1:9000/ ProxyPassReverse / http://127.0.0.1:9000/ diff --git a/tools/apache-hosts/sake.gs.nintendowifi.net.conf b/tools/apache-hosts/sake.gs.nintendowifi.net.conf index ab854a6..2e6ed0b 100644 --- a/tools/apache-hosts/sake.gs.nintendowifi.net.conf +++ b/tools/apache-hosts/sake.gs.nintendowifi.net.conf @@ -1,9 +1,9 @@ ServerAdmin webmaster@localhost - ServerName sake.gs.nintendowifi.net - ServerAlias sake.gs.nintendowifi.net *.sake.gs.nintendowifi.net - ServerAlias secure.sake.gs.nintendowifi.net - ServerAlias secure.sake.gs.nintendowifi.net *.secure.sake.gs.nintendowifi.net + ServerName sake.gs.${HOST} + ServerAlias sake.gs.${HOST} *.sake.gs.${HOST} + ServerAlias secure.sake.gs.${HOST} + ServerAlias secure.sake.gs.${HOST} *.secure.sake.gs.${HOST} ProxyPass / http://127.0.0.1:8000/ From 61ef23906481a9bf9448413196e43117bf4d923f Mon Sep 17 00:00:00 2001 From: Florens Pauwels Date: Sun, 24 Jul 2022 18:09:00 +0200 Subject: [PATCH 4/4] Separate vhosts for docker --- docker-compose.yml | 4 ++-- tools/apache-hosts/dls1.nintendowifi.net.conf | 6 +++--- .../apache-hosts/gamestats.gs.nintendowifi.net.conf | 4 ++-- .../apache-hosts/gamestats2.gs.nintendowifi.net.conf | 4 ++-- .../nas-naswii-conntest.nintendowifi.net.conf | 12 ++++++------ tools/apache-hosts/sake.gs.nintendowifi.net.conf | 8 ++++---- tools/{ => docker}/apache-hosts/Dockerfile | 7 +++++-- tools/docker/apache-hosts/dls1.nintendowifi.net.conf | 9 +++++++++ .../apache-hosts/gamestats.gs.nintendowifi.net.conf | 8 ++++++++ .../apache-hosts/gamestats2.gs.nintendowifi.net.conf | 10 ++++++++++ .../nas-naswii-conntest.nintendowifi.net.conf | 12 ++++++++++++ .../apache-hosts/sake.gs.nintendowifi.net.conf | 11 +++++++++++ 12 files changed, 74 insertions(+), 21 deletions(-) rename tools/{ => docker}/apache-hosts/Dockerfile (86%) create mode 100644 tools/docker/apache-hosts/dls1.nintendowifi.net.conf create mode 100644 tools/docker/apache-hosts/gamestats.gs.nintendowifi.net.conf create mode 100644 tools/docker/apache-hosts/gamestats2.gs.nintendowifi.net.conf create mode 100644 tools/docker/apache-hosts/nas-naswii-conntest.nintendowifi.net.conf create mode 100644 tools/docker/apache-hosts/sake.gs.nintendowifi.net.conf diff --git a/docker-compose.yml b/docker-compose.yml index d5c8854..999b70d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: proxy: build: - context: tools/apache-hosts + context: tools/docker/apache-hosts # environment: -# - HOST=example.com +# - DWC_HOST=example.com network_mode: "host" diff --git a/tools/apache-hosts/dls1.nintendowifi.net.conf b/tools/apache-hosts/dls1.nintendowifi.net.conf index 1b46827..fda65ea 100644 --- a/tools/apache-hosts/dls1.nintendowifi.net.conf +++ b/tools/apache-hosts/dls1.nintendowifi.net.conf @@ -1,8 +1,8 @@ ServerAdmin webmaster@localhost - ServerName dls1.${HOST} - ServerAlias "dls1.${HOST}" - ServerAlias "dls1.${HOST}, dls1.${HOST}" + ServerName dls1.nintendowifi.net + ServerAlias "dls1.nintendowifi.net" + ServerAlias "dls1.nintendowifi.net, dls1.nintendowifi.net" ProxyPreserveHost On ProxyPass / http://127.0.0.1:9003/ ProxyPassReverse / http://127.0.0.1:9003/ diff --git a/tools/apache-hosts/gamestats.gs.nintendowifi.net.conf b/tools/apache-hosts/gamestats.gs.nintendowifi.net.conf index df9a761..dc67950 100644 --- a/tools/apache-hosts/gamestats.gs.nintendowifi.net.conf +++ b/tools/apache-hosts/gamestats.gs.nintendowifi.net.conf @@ -1,7 +1,7 @@ ServerAdmin webmaster@localhost - ServerName gamestats.gs.${HOST} - ServerAlias "gamestats.gs.${HOST}, gamestats.gs.${HOST}" + ServerName gamestats.gs.nintendowifi.net + ServerAlias "gamestats.gs.nintendowifi.net, gamestats.gs.nintendowifi.net" ProxyPreserveHost On ProxyPass / http://127.0.0.1:9002/ ProxyPassReverse / http://127.0.0.1:9002/ diff --git a/tools/apache-hosts/gamestats2.gs.nintendowifi.net.conf b/tools/apache-hosts/gamestats2.gs.nintendowifi.net.conf index 21da7b9..3f79350 100644 --- a/tools/apache-hosts/gamestats2.gs.nintendowifi.net.conf +++ b/tools/apache-hosts/gamestats2.gs.nintendowifi.net.conf @@ -1,7 +1,7 @@ ServerAdmin webmaster@localhost - ServerName gamestats2.gs.${HOST} - ServerAlias "gamestats2.gs.${HOST}, gamestats2.gs.${HOST}" + ServerName gamestats2.gs.nintendowifi.net + ServerAlias "gamestats2.gs.nintendowifi.net, gamestats2.gs.nintendowifi.net" ProxyPreserveHost On diff --git a/tools/apache-hosts/nas-naswii-conntest.nintendowifi.net.conf b/tools/apache-hosts/nas-naswii-conntest.nintendowifi.net.conf index 68fe032..94da24c 100644 --- a/tools/apache-hosts/nas-naswii-conntest.nintendowifi.net.conf +++ b/tools/apache-hosts/nas-naswii-conntest.nintendowifi.net.conf @@ -1,11 +1,11 @@ ServerAdmin webmaster@localhost - ServerName naswii.${HOST} - ServerAlias "naswii.${HOST}, naswii.${HOST}" - ServerAlias "nas.${HOST}" - ServerAlias "nas.${HOST}, nas.${HOST}" - ServerAlias "conntest.${HOST}" - ServerAlias "conntest.${HOST}, conntest.${HOST}" + ServerName naswii.nintendowifi.net + ServerAlias "naswii.nintendowifi.net, naswii.nintendowifi.net" + ServerAlias "nas.nintendowifi.net" + ServerAlias "nas.nintendowifi.net, nas.nintendowifi.net" + ServerAlias "conntest.nintendowifi.net" + ServerAlias "conntest.nintendowifi.net, conntest.nintendowifi.net" ProxyPreserveHost On ProxyPass / http://127.0.0.1:9000/ ProxyPassReverse / http://127.0.0.1:9000/ diff --git a/tools/apache-hosts/sake.gs.nintendowifi.net.conf b/tools/apache-hosts/sake.gs.nintendowifi.net.conf index 2e6ed0b..ab854a6 100644 --- a/tools/apache-hosts/sake.gs.nintendowifi.net.conf +++ b/tools/apache-hosts/sake.gs.nintendowifi.net.conf @@ -1,9 +1,9 @@ ServerAdmin webmaster@localhost - ServerName sake.gs.${HOST} - ServerAlias sake.gs.${HOST} *.sake.gs.${HOST} - ServerAlias secure.sake.gs.${HOST} - ServerAlias secure.sake.gs.${HOST} *.secure.sake.gs.${HOST} + ServerName sake.gs.nintendowifi.net + ServerAlias sake.gs.nintendowifi.net *.sake.gs.nintendowifi.net + ServerAlias secure.sake.gs.nintendowifi.net + ServerAlias secure.sake.gs.nintendowifi.net *.secure.sake.gs.nintendowifi.net ProxyPass / http://127.0.0.1:8000/ diff --git a/tools/apache-hosts/Dockerfile b/tools/docker/apache-hosts/Dockerfile similarity index 86% rename from tools/apache-hosts/Dockerfile rename to tools/docker/apache-hosts/Dockerfile index 0083e6a..658a31a 100644 --- a/tools/apache-hosts/Dockerfile +++ b/tools/docker/apache-hosts/Dockerfile @@ -4,13 +4,16 @@ ENV APACHE_LOG_DIR=/usr/local/apache2/logs # Change this if you have your own domain name set up # Otherwise, you will need to set up a DNS server to point nintendowifi.net to your IP address -ENV HOST=nintendowifi.net +ENV DWC_HOST=nintendowifi.net -# TODO: do in one line +# vhost config RUN echo $'IncludeOptional /usr/local/apache2/vhost.d/*.conf\n\ ServerName localhost\n\ HttpProtocolOptions Unsafe' >> conf/httpd.conf + +# Enable proxy module RUN sed -i 's/^#LoadModule proxy_module/LoadModule proxy_module/' conf/httpd.conf RUN sed -i 's/^#LoadModule proxy_http_module/LoadModule proxy_http_module/' conf/httpd.conf +# Copy vhosts COPY *.conf vhost.d/ diff --git a/tools/docker/apache-hosts/dls1.nintendowifi.net.conf b/tools/docker/apache-hosts/dls1.nintendowifi.net.conf new file mode 100644 index 0000000..5c154da --- /dev/null +++ b/tools/docker/apache-hosts/dls1.nintendowifi.net.conf @@ -0,0 +1,9 @@ + + ServerAdmin webmaster@localhost + ServerName dls1.${DWC_HOST} + ServerAlias "dls1.${DWC_HOST}" + ServerAlias "dls1.${DWC_HOST}, dls1.${DWC_HOST}" + ProxyPreserveHost On + ProxyPass / http://127.0.0.1:9003/ + ProxyPassReverse / http://127.0.0.1:9003/ + diff --git a/tools/docker/apache-hosts/gamestats.gs.nintendowifi.net.conf b/tools/docker/apache-hosts/gamestats.gs.nintendowifi.net.conf new file mode 100644 index 0000000..be30eb7 --- /dev/null +++ b/tools/docker/apache-hosts/gamestats.gs.nintendowifi.net.conf @@ -0,0 +1,8 @@ + + ServerAdmin webmaster@localhost + ServerName gamestats.gs.${DWC_HOST} + ServerAlias "gamestats.gs.${DWC_HOST}, gamestats.gs.${DWC_HOST}" + ProxyPreserveHost On + ProxyPass / http://127.0.0.1:9002/ + ProxyPassReverse / http://127.0.0.1:9002/ + diff --git a/tools/docker/apache-hosts/gamestats2.gs.nintendowifi.net.conf b/tools/docker/apache-hosts/gamestats2.gs.nintendowifi.net.conf new file mode 100644 index 0000000..d42b51f --- /dev/null +++ b/tools/docker/apache-hosts/gamestats2.gs.nintendowifi.net.conf @@ -0,0 +1,10 @@ + + ServerAdmin webmaster@localhost + ServerName gamestats2.gs.${DWC_HOST} + ServerAlias "gamestats2.gs.${DWC_HOST}, gamestats2.gs.${DWC_HOST}" + + ProxyPreserveHost On + + ProxyPass / http://127.0.0.1:9002/ + ProxyPassReverse / http://127.0.0.1:9002/ + diff --git a/tools/docker/apache-hosts/nas-naswii-conntest.nintendowifi.net.conf b/tools/docker/apache-hosts/nas-naswii-conntest.nintendowifi.net.conf new file mode 100644 index 0000000..cf33ed9 --- /dev/null +++ b/tools/docker/apache-hosts/nas-naswii-conntest.nintendowifi.net.conf @@ -0,0 +1,12 @@ + + ServerAdmin webmaster@localhost + ServerName naswii.${DWC_HOST} + ServerAlias "naswii.${DWC_HOST}, naswii.${DWC_HOST}" + ServerAlias "nas.${DWC_HOST}" + ServerAlias "nas.${DWC_HOST}, nas.${DWC_HOST}" + ServerAlias "conntest.${DWC_HOST}" + ServerAlias "conntest.${DWC_HOST}, conntest.${DWC_HOST}" + ProxyPreserveHost On + ProxyPass / http://127.0.0.1:9000/ + ProxyPassReverse / http://127.0.0.1:9000/ + diff --git a/tools/docker/apache-hosts/sake.gs.nintendowifi.net.conf b/tools/docker/apache-hosts/sake.gs.nintendowifi.net.conf new file mode 100644 index 0000000..7d528a8 --- /dev/null +++ b/tools/docker/apache-hosts/sake.gs.nintendowifi.net.conf @@ -0,0 +1,11 @@ + + ServerAdmin webmaster@localhost + ServerName sake.gs.${DWC_HOST} + ServerAlias sake.gs.${DWC_HOST} *.sake.gs.${DWC_HOST} + ServerAlias secure.sake.gs.${DWC_HOST} + ServerAlias secure.sake.gs.${DWC_HOST} *.secure.sake.gs.${DWC_HOST} + + ProxyPass / http://127.0.0.1:8000/ + + CustomLog ${APACHE_LOG_DIR}/access.log combined +