我正在尝试在代理后面的 Docker 容器中设置一个 shibboleth 来工作。
目前,我能够重定向到 shibboleth idp 页面,在那里我可以输入我的登录详细信息,然后 shibboleth 将对我进行身份验证。当它尝试重定向回时,会失败并显示 404:https://my-service.org/Shibboleth.sso/SAML2/POST
我不知道这是 apache 的问题还是 shibboleth 配置的问题。
有一台服务器上运行着 apache 和 docker。这里的 apache 代理流量到同一台服务器上运行的 docker 容器。我已将 DNS 指向代理的域名。我们将其称为“my-service.org”。my-service.org 的 apache 代理配置如下:
<IfModule mod_ssl.c>
<VirtualHost *:80>
ServerName my-service.org
ServerAdmin [email protected]
DocumentRoot /var/www/html/my-service
Redirect permanent / https://my-service.org/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost _default_:443>
ServerName my-service.org
ServerAdmin [email protected]
DocumentRoot /var/www/html/my-service
ErrorLog ${APACHE_LOG_DIR}/docker-dev/my-service.log
CustomLog ${APACHE_LOG_DIR}/docker-dev/my-service_ssl_access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/blah.crt
SSLCertificateKeyFile /etc/ssl/private/blah.key
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4
SSLProtocol All -SSLv2 -SSLv3
SSLCompression off
SSLHonorCipherOrder on
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
RequestHeader set X-Forwarded-SSL expr=%{HTTPS}
ProxyPass / http://127.0.0.1:8088/
ProxyPassReverse / http://127.0.0.1:8088/
</VirtualHost>
</IfModule>
“my-service”容器基于“php:7-apache-buster”容器,并使用 shibd 运行 apache。它是 docker-compose 堆栈的一部分。容器的 apache 配置为:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/my-service
<Directory /var/www/html/my-service/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order deny,allow
Allow from all
</Directory>
<Location "/shibboleth_login.php">
AuthType shibboleth
ShibRequestSetting requireSession 1
ShibUseHeaders On
require valid-user
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
就像我说的,一切都正常,直到从 shibboleth idp 重定向回 SP,出现 404 错误。日志没有告诉我太多信息,但是当我加载容器 apache 配置时出现了错误日志:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.6. Set the 'ServerName' directive globally to suppress this message
我不确定这是否会对情况产生影响。
我认为可能会产生影响的一件事是,我已经设置了 shibboleth 来处理 SSL:
<Sessions lifetime="28800" timeout="3600" relayState="ss:mem"
checkAddress="false" handlerSSL="true" cookieProps="https">
但是我的容器 apache 配置仅定义了一个 HTTP 虚拟主机块。如您所见,代理通过X-Forwarded-Proto
和X-Forwarded-SSL
标头将协议传递给容器。我需要这些用于“my-service”php 应用程序,但不确定它们是否会影响 shibboleth。与 idp 的初始交互工作正常,只是重定向回不起作用。
答案1
我发现我需要添加ServerName
如下属性:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/my-service
ServerName https://my-service.org:443
UseCanonicalName On
<Directory /var/www/html/my-service/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order deny,allow
Allow from all
</Directory>
<Location "/shibboleth_login.php">
AuthType shibboleth
ShibRequestSetting requireSession 1
ShibUseHeaders On
require valid-user
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>