Shinyproxy: 仅在 https (443) 上运行 Shinyproxy

创建于 2018-12-21  ·  25评论  ·  资料来源: openanalytics/shinyproxy

你好,

曾尝试仅在 https 上设置 ShinyProxy。 根据文档,这似乎是可能的 - https://www.shinyproxy.io/security/#https -ssl-tls

请注意,当只有 https 可用(即在 nginx 中没有配置来自 http 的重定向)时,需要将以下内容添加到 application.yml 以使用转发头:
服务器:
useForwardHeaders: 真

问题在于,当仅使用 https、NGINX 入口和 OpenID 进行设置时,https 方案不会从 NGINX 入口传递到 ShinyProxy 容器,这反过来又会导致许多 OpenId 问题。 即:

  • Shinyproxy 在 https 上为 OpenID 生成的返回 URL 是用 http 生成的

发生这种情况的原因是 ShinyProxy 在这里使用了默认代码 - spring-security DefaultOAuth2AuthorizationRequestResolver.java # L141

最有用的评论

设法修复它。
这段代码

 server:
      useForwardHeaders: true

需要在proxy:

所有25条评论

@garyallenkt你能解决这个问题吗?
谢谢!

关于这个问题的任何更新?

OpenAnalytics 在帮助解决这个问题方面做得很好。

您应该能够获得最新版本的 ShinyProxy (2.3.0) 并按照此处的更新文档进行操作 - https://www.shinyproxy.io/security/#https -ssl-tls

祝你好运。

@garyallenkt

感谢你的快速回复。 我尝试使用最新版本,但在我的情况下问题仍然存在。 我在 Iframe 中嵌入了整个 Shinyproxy。 为了登录,服务器将HTTPS连接重定向到大多数浏览器不允许的HTTP连接。 你知道我该如何解决这个问题吗?

问候

@fmichielssen

我正在使用来自Telethon kids repo的叉子,他们也使用 2.3.0,但为了确保我也提取了 openanalytics 的图像。 供您参考,这是我的配置。

docker_compose.yaml

version: "3.6"
services:
  nginx:
    image: nginx:alpine
    container_name: tki_nginx
    restart: on-failure
    networks:
      - tki-net
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    ports:
      - 80:80
      - 443:443
    command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
    depends_on:
      - shinyproxy

  certbot:
    image: certbot/certbot
    container_name: certbot
    restart: on-failure
    volumes:
      - ./data/certbot/conf:/etc/letsencrypt
      - ./data/certbot/www:/var/www/certbot
    entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"

  influxdb:
    image: influxdb:1.7.3-alpine
    container_name: tki_influxdb
    restart: on-failure
    volumes:
      - ./run_first_time.sh:/home/run_first_time.sh
      - type: volume
        source: shinyproxy_usage
        target: /var/lib/influxdb
        volume:
          nocopy: true
    networks:
      - tki-net
    ports:
      - 8083:8083
      - 8086:8086

  shinyproxy:
    depends_on:
      - influxdb
    image: openanalytics/shinyproxy
    container_name: open_analytics_shinyproxy
    restart: on-failure
    networks:
      - tki-net
    volumes:
      - ./application.yml:/opt/shinyproxy/application.yml
      - /var/run/docker.sock:/var/run/docker.sock
    expose:
      - 8080


networks:
  tki-net:
    name: tki-net

volumes:
  shinyproxy_usage:

应用程序.yaml

proxy:
  title: Lorem ipsum

  hide-navbar: true
  landing-page: /
  heartbeat-rate: 10000
  heartbeat-timeout: 600000
  port: 8080
  docker:
    internal-networking: true
  authentication: openid
  openid:
    auth-url: https://lorem-ipsum.auth0.com/authorize
    token-url: https://lorem-ipsumauth0.com/oauth/token
    jwks-url: https://lorem-ipsum.auth0.com/.well-known/jwks.json
    client-id: SUPERCOOL
    client-secret: SUPERCOOLSECRET

  server:
      useForwardHeaders: true
  specs:
  - id: lorem_ipsum
    display-name: Lorem Ipsum
    description:  
    container-cmd: ["R", "-e", "shiny::runApp('/root/app')"]
    container-image: lorem/ipsum
    container-network: tki-net
    container-env:
      user: "shiny"
      environment:
        - APPLICATION_LOGS_TO_STDOUT=false
  usage-stats-url: http://influxdb:8086/write?db=shinyproxy_usagestats

和 nginx.conf

worker_processes 1;
events {
  worker_connections 1024;
}

http {
  sendfile on;
  upstream tki_shinyproxy {
    server open_analytics_shinyproxy:8080;
  }


  server {
    listen 80;
    server_name example.org;
    server_tokens off;
  }

  server {
    listen 443;
    server_name example.org;
    server_tokens off;

    ssl on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;


    # SSL 
    ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;


    location / {
      proxy_pass http://tki_shinyproxy;

      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_read_timeout 600s;

      proxy_redirect off;
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
    }
  }
}

任何可能的更新? @garyallenkt @fmichielssen

设法修复它。
这段代码

 server:
      useForwardHeaders: true

需要在proxy:

server确实是一个顶级块,而不是在proxy

不幸的是,我在使用 Shinyproxy 2.3.1 时遇到了同样的问题

我在 application.yml 文件中的代理块之外有这个块

服务器:
useForwardHeaders: 真

并且我按照文档中的描述设置了 Nginx 代理。 我也(测试我是否只是在设置 Apache 服务器时犯了一些愚蠢的 ngnix 错误并且遇到了完全相同的问题)。

我的 Nginx 配置块是:

server {
  listen                80;
  server_name           mydomain.com;
  rewrite     ^(.*)     https://$server_name$1 permanent;
}

server {
  listen                443 ssl;
  server_name           mydomain.com;
  access_log            /var/log/nginx/shinyproxy.access.log;
  error_log             /var/log/nginx/shinyproxy.error.log error;

  ssl on;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

  ssl_certificate      <path to crt>
  ssl_certificate_key   <path to key> 

   location / {
       proxy_pass          http://127.0.0.1:3600/;

       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       proxy_read_timeout 600s;

       proxy_redirect    off;
       proxy_set_header  Host             $http_host;
       proxy_set_header  X-Real-IP        $remote_addr;
       proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
       proxy_set_header  X-Forwarded-Proto $scheme;
     }

}

有没有人对可能出现的问题有任何想法? 甚至是如何解决它的想法?

有什么错误? 你能像我一样分享你的配置文件吗? 或许我可以帮你

@greenspray感谢您的浏览! 我真的被这个难住了! 我的 Nginx 在上面的评论中对其进行了配置,这就是我的 application.yml 的样子:

除了更改端口和添加 serverforward 标题行之外,我还尝试使所有内容与安装时完全一样。 我什至用闪亮的代理 2.3.0 对此进行了测试,因为这似乎对这个线程上的每个人都有效,但也有同样的问题。

proxy:
  title: My Title
  logo-url: http://www.openanalytics.eu/sites/www.openanalytics.eu/themes/oa/logo.png
  landing-page: /
  heartbeat-rate: 10000
  heartbeat-timeout: 60000
  port: 3600
  authentication: simple
  admin-groups: scientists
  users:
  - name: jack
    password: password1
    groups: scientists
  - name: jeff
    password: password1
    groups: mathematicians
  # Docker configuration
  docker:
    cert-path: /home/none
    url: http://localhost:2375
    port-range-start: 20000
  specs:
  - id: 01_hello
    display-name: Hello Application
    description: Application which demonstrates the basics of a Shiny app
    container-cmd: ["R", "-e", "shinyproxy::run_01_hello()"]
    container-image: openanalytics/shinyproxy-demo
    access-groups: [scientists, mathematicians]

server:
  useForwardHeaders: true

logging:
  file:
    shinyproxy3.log

我还使用 apache 作为网络服务器进行了测试,但我遇到了同样的问题。 我目前的两个理论是我的 application.yml 设置有问题,或者因为我不理解代理/反向代理,所以我的代理块中的某些东西允许重定向到 http。

@Claire-Kelley 你的确切错误是什么?

@greenspray9我没有收到错误! 它工作得很好,所以当我去我的网站时,我可以看到闪亮的代理登录页面,它是通过 HTTPS 提供的(这是所需的行为)。 问题是,当我登录(现在使用简单的身份验证)时,页面开始通过 HTTP(不是 HTTPS-这就是问题!)

@ckelley-ct 抱歉,我没有您想要的登录类型的经验。 也许发生了某种重定向?

我有同样的问题,你找到解决方案了吗?

@HEPBO3AH是的,我做到了 - 对我来说,问题在于不安全的图像(行 logo-url:http://www.openanalytics.eu/sites/www.openanalytics.eu/themes/oa/logo.png 在上面的示例代码)。 如果您将其更改为通过 https 提供的图像或将其删除,则问题会解决。

@HEPBO3AH @ckelley-ct 仅供参考,我们已将图像移至https://www.openanalytics.eu/shinyproxy/logo.png

我设法使用 nginx 制作反向代理并使用简单的身份验证安全登录,但是一旦我尝试使用 openid 它就会失败,因为它使用 http 作为回调协议:

https://login.microsoftonline.com/9ac05e7d-e6a1-433a-9801-a60642903c2b/oauth2/authorize?response_type=code&client_id=d1abf394-b312-4717-a1c4-daaeee4f3b28&scope=openid%20email&state=5ZEbvVrVKBGpwId02I91SNRN-oPSbqkSR9oOlj7PRRQ%3D&redirect_uri=http : //52.152.166.27/login/oauth2/code/shinyproxy&nonce=EhOFxVuVRksPOxd0hG-CKPDd2s78bhFIzSSC_PPU5-Q

出现错误 AADSTS50011:请求中指定的回复 URL 与为应用程序配置的回复 URL 不匹配:'d1abf394-b312-4717-a1c4-daaeee4f3b28'。

这是我用于 Shinyproxy 2.4.0 的 application.yml,Shiny proxy 2.3.1 似乎可以从 microsoft edge 运行

proxy:
  title: Open Analytics Shiny Proxy
  logo-url: https://www.openanalytics.eu/shinyproxy/logo.png
  landing-page: /
  heartbeat-rate: 10000
  heartbeat-timeout: 60000
  port: 8080
  authentication: openid
  admin-groups: scientists
  #bind-address: 127.0.0.1
  # Example: 'simple' authentication configuration
  users:
  - name: jack
    password: password
    groups: scientists
  - name: jeff
    password: password
    groups: mathematicians
  # Example: 'openid' authentication configuration
  openid:
    auth-url: https://login.microsoftonline.com/9ac05e7d-e6a1-433a-9801-a60642903c2b/oauth2/authorize
    token-url: https://login.microsoftonline.com/9ac05e7d-e6a1-433a-9801-a60642903c2b/oauth2/token
    jwks-url: https://login.microsoftonline.com/common/discovery/keys
    client-id: d1abf394-b312-4717-a1c4-daaeee4f3b28
    client-secret: xxx
  # Docker configuration
  docker:
    container-backend: docker
    port-range-start: 20000
    container-protocol: https
  specs:
  - id: euler
    display-name: Euler's number
    #container-cmd: ["R", "-e", "shiny::runApp('/root/euler')"]
    container-image: euler
    access-groups: scientists


server:
    useForwardHeaders: true

logging:
  file:
    shinyproxy.log

我设法使用 nginx 制作反向代理并使用简单的身份验证安全登录,但是一旦我尝试使用 openid 它就会失败,因为它使用 http 作为回调协议:

https://login.microsoftonline.com/9ac05e7d-e6a1-433a-9801-a60642903c2b/oauth2/authorize?response_type=code&client_id=d1abf394-b312-4717-a1c4-daaeee4f3b28&scope=openid%20email&state=5ZEbvVrVKBGpwId02I91SNRN-oPSbqkSR9oOlj7PRRQ%3D&redirect_uri=http : //52.152.166.27/login/oauth2/code/shinyproxy&nonce=EhOFxVuVRksPOxd0hG-CKPDd2s78bhFIzSSC_PPU5-Q

出现错误 AADSTS50011:请求中指定的回复 URL 与为应用程序配置的回复 URL 不匹配:'d1abf394-b312-4717-a1c4-daaeee4f3b28'。

2.4对我来说同样的错误

@danielfm123@roberts2727所以使用 ShinyProxy 2.4,以下配置将不再起作用:

server:
    useForwardHeaders: true

相反,您必须使用:

server:
  forward-headers-strategy: native

你能报告一下这是否为你解决了问题吗?

问题解决了! 谢谢你,先生。

是的,它可以工作,但会杀死包 DT

ShinyProxy 2.4 以下配置

https://www.shinyproxy.io/security/ 上是否值得一提

@shosaco,这已经添加到我们的新网站: https: //www.shinyproxy.io/documentation/security/#forward -headers。 您指向的 URL 是旧网站的剩余部分,我现在对其进行了清理。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

algo-se picture algo-se  ·  6评论

benkates picture benkates  ·  3评论

thomas-chauvet picture thomas-chauvet  ·  5评论

Bertusian picture Bertusian  ·  5评论

dylancis picture dylancis  ·  3评论