diff --git a/docs/docker/nginx-proxy with proxy authentication/README.md b/docs/docker/nginx-proxy with proxy authentication/README.md new file mode 100644 index 000000000..fda7a7871 --- /dev/null +++ b/docs/docker/nginx-proxy with proxy authentication/README.md @@ -0,0 +1,15 @@ +This is a further example combining the power of nginx with the reverse proxy authentication service, [Authelia](https://github.com/authelia/authelia). + +Please refer to the appropriate documentation on how to setup the reverse proxy, authentication, and networks. + +Ensure users have been configured for Authelia, and that the endpoint that recipes is pointed to is protected, but available. + +There is a good guide to the other additional files that need to be added to your Nginx set up at the [Authelia Docs](https://docs.authelia.com/deployment/supported-proxies/nginx.html). + +Remember to add the appropriate environment variables to `.env` file: +``` +VIRTUAL_HOST= +LETSENCRYPT_HOST= +LETSENCRYPT_EMAIL= +PROXY_HEADER= +``` \ No newline at end of file diff --git a/docs/docker/nginx-proxy with proxy authentication/docker-compose.yml b/docs/docker/nginx-proxy with proxy authentication/docker-compose.yml new file mode 100644 index 000000000..db36ac5dd --- /dev/null +++ b/docs/docker/nginx-proxy with proxy authentication/docker-compose.yml @@ -0,0 +1,43 @@ +version: "3" +services: + db_recipes: + restart: always + image: postgres:11-alpine + volumes: + - ./postgresql:/var/lib/postgresql/data + env_file: + - ./.env + networks: + - default + + web_recipes: + image: vabene1111/recipes + restart: always + env_file: + - ./.env + volumes: + - ./staticfiles:/opt/recipes/staticfiles + - ./mediafiles:/opt/recipes/mediafiles + depends_on: + - db_recipes + networks: + - default + + nginx_recipes: + image: nginx:mainline-alpine + restart: always + env_file: + - ./.env + volumes: + - ./nginx/conf.d:/etc/nginx/conf.d + - ./staticfiles:/static + - ./mediafiles:/media + networks: + - default + - nginx-proxy + +networks: + default: + nginx-proxy: + external: + name: nginx-proxy \ No newline at end of file diff --git a/docs/docker/nginx-proxy with proxy authentication/nginx/conf.d/Recipes.conf b/docs/docker/nginx-proxy with proxy authentication/nginx/conf.d/Recipes.conf new file mode 100644 index 000000000..f93ca12c5 --- /dev/null +++ b/docs/docker/nginx-proxy with proxy authentication/nginx/conf.d/Recipes.conf @@ -0,0 +1,37 @@ +server { + listen 80; + server_name localhost; + + client_max_body_size 16M; + + # serve static files + location /static/ { + alias /static/; + } + # serve media files + location /media/ { + alias /media/; + } + + # Authelia endpoint for authentication requests + include /config/nginx/auth.conf; + + # pass requests for dynamic content to gunicorn + location / { + proxy_set_header Host $host; + proxy_pass http://web_recipes:8080; + + # Ensure Authelia is specifically required for this endpoint + # This line is important as it will return a 401 error if the user doesn't have access + include /config/nginx/authelia.conf; + + auth_request_set $user $upstream_http_remote_user; + proxy_set_header REMOTE-USER $user; + } + + # Required to allow user to logout of authentication from within Recipes + # Ensure the below is changed to actual the authentication url + location /accounts/logout/ { + return 301 http:///logout + } +} \ No newline at end of file