我在example.org/portia/test上有一个由 Nginx 映射的容器,结构如下:
- 容器仅公开端口 9001,作为代理的 Apache 实例正在侦听该端口。
- 一个 Django 服务器在 8000 上运行,/api 和 /server_capabilities 的所有流量都发送给他。
- 另一个 Django 服务器在 9002 上运行,它处理 /ws 路径上的 websocket。
我正在尝试使用 Apache 的 mod_auth_openidc 插件添加 OpenIdConnect 身份验证,我想保护整个虚拟主机。
到目前为止,我到达了 auth-example.org 上的正确登录页面,我使用我的凭据登录,并且身份验证服务器使用正确的 URI 重定向我。Ngnix 用 400 错误回答我。
auth 服务器被 mydomain.org 中的多个应用程序使用,所以我猜我的 Apache 配置文件有问题。
为清楚起见,我无法触及 Nginx 或身份验证服务器配置文件。
apache_site.conf
<VirtualHost *:9001>
ServerAdmin webmaster@localhost
DocumentRoot /app/portiaui/dist
ServerName www.example.org
ServerAlias example.org
#ProxyRequests On
Alias /static /app/portiaui/dist
OIDCProviderMetadataURL https://www.auth-example.org/auth/realms/master/.wel$
OIDCRedirectURI https://example.org/portia/test/callback
OIDCCryptoPassphrase <much secret>
OIDCClientID portia
OIDCClientSecret <much private>
OIDCCookiePath example.org/portia/test/
OIDCCookieDomain example.org
<Location /static>
Require all granted
</Location>
<Location /api>
Require all granted
ProxyPass http://127.0.0.1:8000/api
ProxyPassReverse http://127.0.0.1:8000/api
ProxyPreserveHost On
</Location>
<Location /server_capabilities>
Require all granted
ProxyPass http://127.0.0.1:8000/server_capabilities
ProxyPassReverse http://127.0.0.1:8000/server_capabilities
ProxyPreserveHost On
</Location>
<Location /ws> # mod_proxy_wstunnel is enabled
RequestHeader set Host "127.0.0.1:9002"
ProxyPreserveHost On
ProxyPass http://127.0.0.1:9002/ws
ProxyPassReverse http://127.0.0.1:9002/ws
</Location>
<Location />
AuthType openid-connect
Require valid-user
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>