All Projects → Siecje → Nginx Auth Proxy

Siecje / Nginx Auth Proxy

Licence: other
Authentication for multiple services using nginx

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Nginx Auth Proxy

External Auth Server
easy auth for reverse proxies
Stars: ✭ 189 (+759.09%)
Mutual labels:  reverse-proxy, authentication, nginx
Bunkerized Nginx
🛡️ Make your web services secure by default !
Stars: ✭ 2,361 (+10631.82%)
Mutual labels:  reverse-proxy, nginx
Nginx
NGINX Accelerated! This is a Docker image that creates a high performance (FAST!), optimized image for NGINX for use with Redis and PHP-FMP. Deliver sites and applications with performance, reliability, security, and scale. This NGINX server offers advanced performance, web and mobile acceleration, security controls, application monitoring, and management.
Stars: ✭ 157 (+613.64%)
Mutual labels:  reverse-proxy, nginx
Ecs Nginx Reverse Proxy
Reference architecture for deploying Nginx on ECS, both as a basic static resource server, and as a reverse proxy in front of a dynamic application server.
Stars: ✭ 245 (+1013.64%)
Mutual labels:  reverse-proxy, nginx
Droxy
a transparent standalone http reverse proxy for docker containers
Stars: ✭ 43 (+95.45%)
Mutual labels:  reverse-proxy, nginx
Noginx
High performance HTTP and reverse proxy server based on Node.js. 基于 Node.js 的高性能 HTTP 及反向代理服务器,类似nginx。
Stars: ✭ 53 (+140.91%)
Mutual labels:  reverse-proxy, nginx
Lightify
a reverse proxy that boosts the web app performance!
Stars: ✭ 187 (+750%)
Mutual labels:  reverse-proxy, nginx
Next Advanced Apollo Starter
Advanced, but minimalistic Next.js pre-configured starter with focus on DX
Stars: ✭ 131 (+495.45%)
Mutual labels:  authentication, nginx
Annon.api
Configurable API gateway that acts as a reverse proxy with a plugin system.
Stars: ✭ 306 (+1290.91%)
Mutual labels:  reverse-proxy, authentication
Ssl Proxy
🔒 Simple zero-config SSL reverse proxy with real autogenerated certificates (LetsEncrypt, self-signed, provided)
Stars: ✭ 427 (+1840.91%)
Mutual labels:  reverse-proxy, nginx
Micro Auth
A microservice that makes adding authentication with Google and Github to your application easy.
Stars: ✭ 466 (+2018.18%)
Mutual labels:  authentication, nginx
Kong
🦍 The Cloud-Native API Gateway
Stars: ✭ 30,838 (+140072.73%)
Mutual labels:  reverse-proxy, nginx
Feathers Vue
A boiler plate template using Feathers with Email Verification, Vue 2 with Server Side Rendering, stylus, scss, jade, babel, webpack, ES 6-8, login form, user authorization, and SEO
Stars: ✭ 195 (+786.36%)
Mutual labels:  authentication, nginx
Ecs Nginx Proxy
Reverse proxy for AWS ECS. Lets you address your docker containers by sub domain.
Stars: ✭ 93 (+322.73%)
Mutual labels:  reverse-proxy, nginx
Nginx Http Shibboleth
Shibboleth auth request module for nginx
Stars: ✭ 168 (+663.64%)
Mutual labels:  authentication, nginx
Authelia
The Single Sign-On Multi-Factor portal for web apps
Stars: ✭ 11,094 (+50327.27%)
Mutual labels:  authentication, nginx
Vouch Proxy
an SSO and OAuth / OIDC login solution for Nginx using the auth_request module
Stars: ✭ 1,239 (+5531.82%)
Mutual labels:  authentication, nginx
Docker Nginx Basic Auth
🔐 Simple Docker image for basic authentication
Stars: ✭ 111 (+404.55%)
Mutual labels:  authentication, nginx
Open Proxy
一键部署被墙网站反向代理; 免翻墙访问被禁网站
Stars: ✭ 274 (+1145.45%)
Mutual labels:  reverse-proxy, nginx
Apisix
The Cloud-Native API Gateway
Stars: ✭ 7,920 (+35900%)
Mutual labels:  reverse-proxy, nginx

NGINX Auth Proxy

Problem

You have multiple services running on the same server on different ports or subdomains. You want passwords to validate against one source of truth. You want to use the same authentication (login and password) for every service without having to login to each one (Single Sign On).

How does it work

Services are running locally on a specific port. For example JupyterHub is running on port 9000 internally. Auth Service is running on port 8000 internally. It can be a Python webserver or anything else as long as it is running on port 8000 internally.

Each request needs to have an auth token, which will be checked by the auth service. If the auth token is valid, route the request to the internal service (ex. port 9000), passing the auth token and any additional headers. If no auth token is provided or the token is not valid then the request will be sent to the auth service login form.

When you login to the auth service it will provide an auth token which will be used for subsequent requests.

Diagram

Using the ngx_http_auth_request_module with LDAP authentication is described in this article https://www.nginx.com/blog/nginx-plus-authenticate-users/.

Adding a new service

  • Add the nginx config to run the service locally on an available port.

  • Configure the new service to authenticate via REMOTE_USER or add the required headers for the service to authenticator.py and include.d/application.include.

  • Restart nginx to reload the nginx configuration.

Run demo

You will need NGINX with the ngx_http_auth_request_module installed.

sudo apt-get install nginx-full
git clone https://github.com/Siecje/nginx-auth-proxy
cd nginx-auth-proxy

Simulate subdomains locally

This will resolve both one.localhost and two.localhost to localhost.

echo "127.0.0.1 one.localhost" | sudo tee -a /etc/hosts
echo "127.0.0.1 two.localhost" | sudo tee -a /etc/hosts

Create self signed certificate

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj '/CN=localhost'
sudo mv cert.pem /etc/ssl/certs/
sudo mv key.pem /etc/ssl/certs/

Configure nginx

sudo rm /etc/nginx/sites-enabled/default
sudo mkdir /etc/nginx/include.d/
sudo ln -s `pwd`/include.d/authentication.include /etc/nginx/include.d/authentication.include
sudo ln -s `pwd`/include.d/application.include /etc/nginx/include.d/application.include
sudo ln -s `pwd`/conf.d/authenticator.conf /etc/nginx/conf.d/authenticator.conf
sudo ln -s `pwd`/conf.d/service1.conf /etc/nginx/conf.d/service1.conf
sudo ln -s `pwd`/conf.d/service2.conf /etc/nginx/conf.d/service2.conf
sudo service nginx restart

Start services

virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
python authenticator.py &
python service1.py &
python service2.py &

When you visit http://one.localhost/ you will be redirected to http://one.localhost/ and need to login. As long as you use the username 'admin' you will be able to access the service.

You will then be able to visit https://two.localhost and login with the same username and password.

Run in production

  • [ ] Implement the authentication logic in ValidUser() in authenticator.py.

  • [ ] Create secret_key file

    • python -c 'import os; print(os.urandom(32))' > secret_key
  • [ ] Add HTTPS certificate to include.d/certificate.include

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].