By Amin Abbaspour
This tutorial demonstrates how to use thenginx-openid-connect module to add authentication and authorization to your NGINX server.We recommend that you log in to follow this quickstart with examples configured for your account.
System Requirements
This tutorial and seed project have been tested with the following:- NGINX Plus R24
Install and Enable nginx-plus-module-njs Module
First, you need to install the nginx-plus-module-njs module for NGINX Plus. Follow the dynamic module installation guide to install packages in your host OS. For Linux distributions that useyum package manager install as follows:
/etc/nginx/nginx.conf file:
Checkout nginx-openid-connect Template Repository
Clonenginx-openid-connect GitHub repository. This repository comes with a template configuration.
Configure with Your Auth0 Application Information
Run theconfigure.sh script inside nginx-openid-connect folder to populate template configuration for your Auth0 application:
Next, add your tenant’s logout URL to openid_connect_configuration.conf file
Set Accept-Encoding Type for Token and JWKS Endpoints
AddAccept-Encoding header in openid_connect.server_conf
Copy OpenID Connect Config Files to NGINX Server
You need to copy four files to the config folder of NGINX server machineConfiguring Auth0 Settings
In your application settings add a new “Allowed Callback URLs” that is equal tohttps://server-fqdn/_codexch.
Then, change “Token Endpoint Authentication Method” to “None” in Auth0 for your Application. This is required for PKCE authorisation code flow.
Passing Headers to Upstream Application
Edit/etc/nginx/conf.d/frontend.conf and add additional headers from id_token to the upstream target: