你好,
我的设置是这样的。
Shinyproxy 在名称为 Shiny-proxy 的 docker 容器中运行。
apache httpd反向代理在shinyproxy之前运行并将其转换为https并在端口为2443的主机上运行
keycloak 也在 docker 容器中运行,但端口在主机上以 8443 打开。
设置,application.xml
keycloak:
realm: shiny
auth-server-url: https://keycloak:8443/auth
#ssl-required: none
ssl-required: external
confidential-port: 2443
verify-token-audience: true
resource: shiny-proxy-p1
credentials-secret: xxxxxxxxxxxx
apache反向代理配置
<VirtualHost *:2443>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/server-cert.pem
SSLCertificateKeyFile /etc/apache2/ssl/server-cert.key
# Server Certificate Chain:
# Point SSLCertificateChainFile at a file containing the
# concatenation of PEM encoded CA certificates which form the
# certificate chain for the server certificate. Alternatively
# the referenced file can be the same as SSLCertificateFile
# when the CA certificates are directly appended to the server
# certificate for convinience.
SSLCertificateChainFile /etc/apache2/ssl/server-ca.crt
<Proxy *>
Allow from *
</Proxy>
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /(.*) ws://shiny-proxy:8080/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /(.*) http://shiny-proxy:8080/$1 [P,L]
ProxyPass / http://shiny-proxy:8080/
ProxyPassReverse / http://shiny-proxy:8080/
ProxyRequests Off
ErrorLog ${APACHE_LOG_DIR}/proxy_error.log
CustomLog ${APACHE_LOG_DIR}/proxy_access.log combined
</VirtualHost>
假设当使用 URL https://lxsqlpocnd04 :2443/ 通过 apache 访问 Shinyprox 时
它将重定向到登录页面,并将登录页面重定向请求重定向到 Keycloak 主机 lxsqlpocnd04 和端口 8443。在该 URL 中有包含 redirect_uri 的查询字符串,但它不是预期的。
网址是这样的
https://lxsqlpocnd04 :8443/auth/realms/shiny/protocol/openid-connect/auth?response_type=code&client_id=shiny-proxy-p1&redirect_uri=http%3A%2F%2Fshiny-proxy%3A8080%2Fsso%2Flogin5&state=0807 e6a9-4768-8cf8-39d77500fea3&login=true&scope=openid
而redirect_uri 是http://shiny-proxy :8080/sso/login 除了https://lxsqlpocnd04 :2443/sso/login
有人可以帮忙吗?
谢谢,
罗宾
你在 application.yml 中设置了吗?
server:
useForwardHeaders: true
从这里: https: //www.shinyproxy.io/security/#https -ssl-tls
不确定 Apache 等价物是什么,但在 nginx 中,这可能是解决您问题的方法:
proxy_set_header Host $http_host;
@aiham谢谢。
我有它的工作。 这是因为缺少 useForwardHeaders: true
我正在使用 useForwardHeaders: true 但仍有问题
@danielfm123
我正在使用 useForwardHeaders: true 但仍有问题
还有另一种可能与 SSL 证书有关。 如果安装在 Keycloak 上的证书不是公共信任的(根和中间 CA 不在 Java 的默认信任列表中),则需要将它们添加到 JRE 默认信任 CA 中。 JRE 是运行您的 Shinyproxy 的那个。
默认位置是JAVA_HOME---> JRE -->lib---> security--> cacerts JAVA_HOME---> JRE -->lib---> security--> cacerts
像这样导入的命令。
keytool -import -noprompt -alias -your-root -file /opt/jboss/your-root.crt -keystore /etc/pki/java/cacerts -storepass changeit
我做到了,它不起作用,我尝试了 Shinyproxy 2.3.1 而不是 2.4.1,它发送了正确的 redirect_uri,但仅适用于某些浏览器,其余的我得到 err_too_many_redirects
您的证书是否公开可信? 我在测试阶段遇到了这个问题,证书不受公众信任。 您需要将根 CA 和中间 CA 导入浏览器可信存储。 每个浏览器都不同,取决于您的操作系统和浏览器。 就我而言,我使用的是 Windows,在将证书导入受信任区域之后,IE 和 Chrome 都可以正常工作。
这是我的建议,
它已通过 certbot 验证.... 我设法使其与 Shinyproxy 2.3.1 和不同的活动目录帐户一起使用...
但是在 Shinyproxy 2.4.1 和 2.4.0 上有一个错误
嗨@danielfm123 ,我在这里检查了一些东西,我无法在ShinyProxy 2.4.0/1 中重现redirect_uri 的任何问题。
你能用以下信息开一个新问题吗? 这样我就可以查看它并查看是否存在错误。
我有同样的问题。
使用 keycloak、apache2 反向代理和 Shinyproxy 2.3.1 进行设置工作正常。 我通过 Docker 运行 Shinyproxy。 Shinyproxy 正确重定向到https://testauth.example.com。
当我切换到 Shinyproxy 2.4.1 时,redirect_uri 包含内部 IP(http://192.168.51.27:8082)而不是可从外部访问的地址,我收到错误:“无效参数:redirect_uri”。
这是我的 application.yml 的相关部分:
proxy:
title: AUTHTEST
hide-navbar: false
template-path: /templates
favicon-path: /www/favicon.png
heartbeat-rate: 10000
heartbeat-timeout: 600000
port: 8080
admin-groups: admin
container-wait-time: 30000
authentication: keycloak
keycloak:
realm: shinyr
auth-server-url: http://192.168.51.122:8080/auth
resource: shinyr
credentials-secret: <secret>
docker:
internal-networking: true
specs:
- id: test
display-name: Euler App
description: Test App
container-cmd: ["R", "-e", "shiny::runApp('/root/euler')"]
container-image: saletelligence/test
container-network: authtest_authtest_net
access-groups: [admin, pm]
logging:
file:
shinyproxy.log
server:
useForwardHeaders: true
这是 apache 配置:
<VirtualHost *:443>
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"
ServerName testauth.example.com
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /(.*) ws://192.168.51.27:8082/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /(.*) http://192.168.51.27:8082/$1 [P,L]
ProxyRequests Off
ProxyPass "/" "http://192.168.51.27:8082/"
ProxyPassReverse "/" "http://192.168.51.27:8082/"
SSLProxyEngine On
SSLEngine On
SSLCertificateFile /etc/apache2/sslcert/example.crt
SSLCertificateKeyFile /etc/apache2/sslcert/example_pem.key
SSLCACertificateFile /etc/apache2/sslcert/example_bundle.pem
</VirtualHost>
嗨@eastclintw00d
请尝试使用:
server:
forward-headers-strategy: "native"
代替
server:
useForwardHeaders: true
谢谢!
嗨@LEDfan
那解决了问题。
谢谢你的快速反应!
这有效,但它会杀死包 DT
@ danielfm123你确定你正在运行 Shinyproxy 2.4.1 吗? DT 对我来说工作正常。
@danielfm123 @eastclintw00d POST 请求(例如由 DT 提出)在使用 OIDC和当前 ShinyProxy (2.4.1)@LEDfan的修复将是即将发布的版本的一部分,但这不是该线程的主题。