From 6d1d647455fc0e754a3067d8a13c5e706c1dc380 Mon Sep 17 00:00:00 2001 From: ChillyEmber Date: Sun, 6 Nov 2022 06:56:50 -0500 Subject: [PATCH] Add nginx.conf with authentication support (#74) * NGINX w/ Authentication * Delete .idea/.idea.neko-rooms-nginx-authentication.dir/.idea directory --- traefik/nginx-auth/README.md | 25 +++++++++++++++ traefik/nginx-auth/docker-compose.yml | 45 +++++++++++++++++++++++++++ traefik/nginx-auth/nginx.conf | 23 ++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 traefik/nginx-auth/README.md create mode 100644 traefik/nginx-auth/docker-compose.yml create mode 100644 traefik/nginx-auth/nginx.conf diff --git a/traefik/nginx-auth/README.md b/traefik/nginx-auth/README.md new file mode 100644 index 0000000..78697d8 --- /dev/null +++ b/traefik/nginx-auth/README.md @@ -0,0 +1,25 @@ +# Installation guide for NGINX as a reverse proxy with authentication + +##How to start: + +First, make sure that you have your `.htpasswd` file created, if you don't, you can follow this guide in the NGINX docs: + +https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/ + +This guide assumes that your `.htpasswd` file is located at `/etc/apache2/.htpasswd`. + +##Installation: + +Download your `docker-compose.yml` file, and make necessary changes to the environment variables, more notably, `NEKO_ROOMS_NAT1TO1` and `NEKO_ROOMS_INSTANCE_URL`. + +Run your docker-compose file, done by running `sudo docker-compose up -d` on Linux in the same directory as your compose file. + +Next, move onto NGINX. First, open up your NGINX config, and make any alterations necessary for the traefik `proxy-pass`. +The Docker IP for the container can also work there, if necessary. +Your NGINX config at this point should be good to go, install and restart NGINX! + +##Certificates: + +IF you wish to have SSL for Neko, you can use certbot to get that done! A guide is linked below for installation. + +https://certbot.eff.org/instructions \ No newline at end of file diff --git a/traefik/nginx-auth/docker-compose.yml b/traefik/nginx-auth/docker-compose.yml new file mode 100644 index 0000000..9a7260c --- /dev/null +++ b/traefik/nginx-auth/docker-compose.yml @@ -0,0 +1,45 @@ +version: "3.5" + +networks: + default: + attachable: true + name: "neko-rooms-traefik" + +services: + traefik: # domain name used in nginx config + image: "traefik:2.4" + restart: "unless-stopped" + environment: + - "TZ=Europe/Vienna" + command: + - "--providers.docker=true" + - "--providers.docker.watch=true" + - "--providers.docker.exposedbydefault=false" + - "--providers.docker.network=neko-rooms-traefik" + - "--entrypoints.web.address=:8080" + volumes: + - "/var/run/docker.sock:/var/run/docker.sock:ro" + + neko-rooms: + image: "m1k1o/neko-rooms:latest" + restart: "unless-stopped" + environment: + - "TZ=Europe/Vienna" + - "NEKO_ROOMS_EPR=59000-59049" + - "NEKO_ROOMS_NAT1TO1=10.8.0.1" # IP address of your server + - "NEKO_ROOMS_TRAEFIK_ENTRYPOINT=web" + - "NEKO_ROOMS_TRAEFIK_NETWORK=neko-rooms-traefik" + - "NEKO_ROOMS_INSTANCE_URL=http://10.8.0.1:8080/" # external URL + - "NEKO_ROOMS_STORAGE_ENABLED=true" + - "NEKO_ROOMS_STORAGE_INTERNAL=/data" + - "NEKO_ROOMS_STORAGE_EXTERNAL=/opt/neko-rooms/data" + - "NEKO_ROOMS_PATH_PREFIX=/rooms/" + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + - "/opt/neko-rooms/data:/data" + labels: + - "traefik.enable=true" + - "traefik.http.services.neko-rooms-frontend.loadbalancer.server.port=8080" + - "traefik.http.routers.neko-rooms.entrypoints=web" + - "traefik.http.routers.neko-rooms.rule=HostRegexp(`{host:.+}`)" + - "traefik.http.routers.neko-rooms.priority=1" diff --git a/traefik/nginx-auth/nginx.conf b/traefik/nginx-auth/nginx.conf new file mode 100644 index 0000000..0f8c83a --- /dev/null +++ b/traefik/nginx-auth/nginx.conf @@ -0,0 +1,23 @@ +server { + server_name [DOMAIN]; + listen 80; + + location / { + proxy_pass http://traefik:8080; # traefik domain (name of the service) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_read_timeout 86400; + auth_basic "Authentication Required"; + auth_basic_user_file /etc/apache2/.htpasswd; + } + + location /rooms { + proxy_pass http://traefik:8080; # traefik domain (name of the service) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_read_timeout 86400; + auth_basic off; + } +} \ No newline at end of file