Security in an R Shiny Application

前端 未结 6 1651
说谎
说谎 2021-01-29 23:54

I want to publish an R Shiny web application (http://www.rstudio.com/shiny/) on the web, but I want to password protect it so that only people with credentials can view what I h

6条回答
  •  甜味超标
    2021-01-30 00:03

    A bit more late, but I've found another option using ngnix as a proxy:

    This guide has been finished by following partially this guideline: https://support.rstudio.com/hc/en-us/articles/213733868-Running-Shiny-Server-with-a-Proxy

    On an Ubuntu 14.04:

    1. Install nginx
    2. Change file config /etc/nginx/nginx.conf to:

    This:

    events {
            worker_connections 768;
            multi_accept on;
    }
    
    http {
    
      map $http_upgrade $connection_upgrade {
          default upgrade;
          ''      close;
        }
    
      server {
        listen XX;
    
    
    
        location / {
          proxy_pass http://localhost:YY;
          proxy_redirect http://localhost:YY/ $scheme://$host/;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection $connection_upgrade;
          proxy_read_timeout 20d;
    
          auth_basic "Restricted Content";
          auth_basic_user_file /etc/nginx/.htpasswd;
        }
      }
    }
    

    XX: Port that the nginx will listen to

    YY: Port that the shiny server uses

    1. Using this tutorial, I added password authentication to the nginx server: https://www.digitalocean.com/community/tutorials/how-to-set-up-password-authentication-with-nginx-on-ubuntu-14-04

    2. Set up the shiny process or the shiny server to only listen to localhost (127.0.0.1)

提交回复
热议问题