Skip to main content
By Amin Abbaspour
This tutorial demonstrates how to use the nginx-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
Please follow the steps below to configure your application using NGINX Plus to work with Auth0 and Open ID Connect.

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 use yum package manager install as follows:
Once you’ve installed it, you need to enable it for NGINX by adding the following line near the top of your /etc/nginx/nginx.conf file:

Checkout nginx-openid-connect Template Repository

Clone nginx-openid-connect GitHub repository. This repository comes with a template configuration.

Configure with Your Auth0 Application Information

Run the configure.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

Add Accept-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 machine

Configuring Auth0 Settings

In your application settings add a new “Allowed Callback URLs” that is equal to https://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:
Edit on GitHub