0

我在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 错误回答我。

使用大量 cookie 发送的请求

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>
4

2 回答 2

0

Hans Z. 的回答建议我也改变OIDCRedirectURI相对路径。

设置OIDCRedirectURI /callback解决了这个问题:我的 Apache 实例不接收整个 URL www.example.org/portia/test/callback,而只接收路径的最后一部分。这是由于前端 Nginx 实例。

于 2019-04-04T17:56:27.637 回答
0

中的cookie路径设置OIDCCookiePath只需要包含实际路径,不需要包含主机。事实上,我会在不使用任何OIDCCookiePathor的情况下开始OIDCCookieDomain

于 2019-04-03T16:05:14.820 回答