NGINX Plus

このチュートリアルでは、nginx-openid-connectモジュールを使用して、NGINXサーバーに認証と認可を追加する方法について説明します。 ログインして、アカウント用に構成された例を参考にこのクイックタートに従うことをお勧めします。

1

システム要件

このチュートリアルとシードプロジェクトは次を使用してテストが完了しています:

  • NGINX Plus R24

2

nginx-plus-module-njsモジュールをインストールして有効にする

まず、NGINX Plusにnginx-plus-module-njsモジュールをインストールする必要があります。

動的モジュールのインストールガイドに従って、ホストOSにパッケージをインストールします。

yumパッケージ管理ツールを使用しているLinuxディストリビューションでは、soのようなモジュールをインストールすることができます:

sudo yum install nginx-plus-module-njs jq

インストールしたら、それをNGINXに有効化する必要があります。次の行を/etc/nginx/nginx.confファイルの最上部近くに追加してください:

load_module modules/ngx_http_js_module.so;

3

nginx-openid-connectテンプレートリポジトリを確認する

nginx-openid-connectリポジトリをクローンします。このリポジトリにはテンプレート構成があります。

git clone https://github.com/nginxinc/nginx-openid-connect

4

Auth0アプリケーションの詳細でNGINXを構成する

nginx-openid-connectフォルダーにあるconfigure.shスクリプトを実行して、テンプレートの構成にAuth0アプリケーションの詳細を入力します。

./configure.sh --auth_jwt_key request \
--client_id {yourClientId} \
--pkce_enable \
https://{yourDomain}/.well-known/openid-configuration

Was this helpful?

/

次に、テナントのログアウトURLopenid_connect_configuration.confファイルに追加します。

5

トークンとJWKSエンドポイントにAccept-Encodingヘッダーを構成する

openid_connect.server_confファイルにAccept-Encodingヘッダーを追加して、 gzipに値を設定します。

6

OpenID Connect構成ファイルをコピーする

4つの構成ファイルをconf.dフォルダーにコピーします。

sudo cp openid_connect.js \ 
frontend.conf \
openid_connect_configuration.conf \
openid_connect.server_conf /etc/nginx/conf.d

Was this helpful?

/

7

Auth0のアプリケーション設定を構成する

Auth0 Dashboardで以下を行います。

  1. [Applications(アプリケーション)] > [Applications(アプリケーション)]に移動し、リストからアプリケーションを選択します。

  2. [Settings(設定)]ビューに切り替えます。

  3. [Application URI(アプリケーションURI)]セクションの[Allowed Callback URLs(許可されているコールバックURL)]にhttps://{yourDomain}/_codexchを追加します。

  4. [Credentials(資格情報)]ビューに切り替えます。

[Application Authentication(アプリケーション認証)]セクションで、認証方法を[None(なし)]に設定します。

8

アップストリームアプリケーションにヘッダーを渡す

IDトークン(JWT)からの追加のヘッダーを/etc/nginx/conf.d/frontend.confファイルでアップストリームの対象に追加します。

Next Steps

Excellent work! If you made it this far, you should now have login, logout, and user profile information running in your application.

This concludes our quickstart tutorial, but there is so much more to explore. To learn more about what you can do with Auth0, check out:

  • Auth0 Dashboard - Learn how to configure and manage your Auth0 tenant and applications
  • Auth0 Marketplace - Discover integrations you can enable to extend Auth0’s functionality

Did it work?

Any suggestion or typo?

Edit on GitHub
Sign Up

Sign up for an or to your existing account to integrate directly with your own tenant.