Nginx community edition
前提条件
このガイドは、以下の条件を満たしていることを前提としています:
- 実行中のCasdoorサービス。 If you haven't installed Casdoor service yet, see Server installation or Try with Docker.
- コンパイル時に
ngx_http_auth_request_moduleモジュールが有効になっているNginxオープンソース版。 See the Nginx auth_request module to enable it. - 認証を有効にしたいウェブサイトがNginx上に正常にデプロイされ、設定されたドメイン名(IPアドレスの使用ではない)でアクセスできる状態であること。
- OAuth2-Proxy (choose one of the two popular options on GitHub):
- oauth2-proxy/oauth2-proxy(この記事で使用)GitHub または Official-Website
- vouch/vouch-proxy GitHub
I. Casdoorの設定
Note: The Casdoor GUI may differ by version; use this article as a reference and adapt to your build.
注記: この記事で言及されているキー、パスワード、ユーザー名、その他の機密情報はすべて例です。 セキュリティ上の理由から、デプロイ時にはそれらを自分の関連する内容に置き換える必要があります。
-
Casdoor管理アカウントにログインします。
-
トップバーで「Identity Authentication」>「Applications」を選択し、「Applications」ページで「Add」をクリックします。

-
プロジェクト情報に基づいてアプリケーション設定を完了します。 この記事では、「Nginx-Community」という例のアプリケーション名を使用します。

-
「Client ID」と「Client Secret」フィールドの値をメモしてください。 これらは後でOAuth2-Proxyを設定する際に使用されます。 次に、「Redirect URL」を
https://project.yourdomain.com/oauth2/callback/として設定します。
-
トップバーで「Casbin Permission Management」>「Roles」を選択し、「Roles」ページで「Add」をクリックします。

-
プロジェクト情報に基づいてロール設定を完了します。 この記事では、「nginx_role」という例のロール名を使用します。

-
(オプション)トップバーで「User Management」>「Users」を選択し、必要に応じて新しいユーザーを追加します。 If the users already exist, skip this step. この記事では、「user」という例のユーザーを作成します。
-
Go back to the "Roles" page mentioned in step 5, edit the
nginx_rolerole, and add the required users to Included Users (e.g. the previously createdbuiltin/user).