-
Notifications
You must be signed in to change notification settings - Fork 5
How to setup a Shiny Server on Amazon AWS
- Create an EC2 instance on AWS
- Install dependencies
- Configure Auth0.com
- Install Shiny Server
- Start/stop
- Upload data with SFTP
- Troubleshooting
- Log in to your Amazon AWS console.
- Create an EC2 instance:
- Instance type:
t3.medium
with 2 vCPUs and 4GB RAM. (This is sufficient for a medium-use Shiny Server) - OS: Ubuntu 18.04 LTS
- EBS storage: 8-30GB
- Open inbound ports: 80, 22, 2222, 443
- Open outbound ports: All
- Instance type:
- Create an Elastic IP and associate it with your newly created instance
- Log in to your instance with your SSH keys (keys created when instance was created)
Run the following bash script to install dependences, including Docker, to your instance.
#!/bin/bash
# update package list
sudo apt-get update -y
# get dependencies
sudo apt-get install -y fish htop wget git nano \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
# get keys
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# add repo
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# get latest package list
sudo apt-get update -y
# install docker
sudo apt-get install -y docker-ce
# ensure docker is installed
docker --version
# download docker compose
curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# make executable
sudo chmod +x /usr/local/bin/docker-compose
# ensure installed
docker-compose --version
# upgrade all upgradable packages
sudo apt-get upgrade -y
Then reboot with reboot 0
, and log in again.
- Go to Auth0.com and create an account.
- Create a "tenant", eg.
my-shiny-staging
- Create an Application (Regular Web App)
- Then in your App, set the following settings:
- Token Endpoint Authentication Method:
None
- Allowed Callback URLs:
mydomain.com/callback
- Allowed Web Origins:
mydomain.com
, and theDomain
listed on top of your App Settings. - Allowed Origins (CORS): same as previous
- Allowed Logout URLs:
mydomain.com
or other domain you want to redirect to after logout
- Token Endpoint Authentication Method:
- The click SAVE CHANGES at the bottom of the page.
- Select Connections -> Social, and unselect Google.
- Select Connections -> Database, and Disable Signups.
- Go to Hosted Pages -> Customize Login Page, and add your logo in the JS if you like.
- Go to Users -> and create your users manually.
- Your Auth0.com tenant is now ready. You'll paste info from this account into your Auth0 config further down in this manual.
cd /home/ubuntu/
git clone https://github.com/mapic/shiny.git
cd shiny
- Replace the
server_name
values with your domain in config/nginx.conf and config/nginx.certbot.conf. - Replace the variables in the
config/nginx.env
file with your Let's Encrypt details.
# copy the template
cp config/auth0.env.default config/auth0.env
Then add your Auth0.com credentials to the config/auth0.env
file. See the wiki for more information on Auth0 settings.
-
cp config/shiny.env.default config/shiny.env
(Then add info if PRO only.) - Optionally edit the
config/shiny-server.conf
. Defaults will work. See the offical documentation for details on configuration settings.
# create config file with user/pass
echo "shiny:YOUR_PASSWORD_HERE:1001:100" > config/sftp.users.conf
Create our named Docker network:
docker network create shiny-network
# start server
bash start-shiny.sh
# show logs
docker-compose logs -f -t
# (use ctrl-c to exit logs and keep containers running)
# stop server
bash stop-shiny.sh
Use an SFTP program like Cyberduck, and connect with the following credentials:
Server: mydomain.com
Username: shiny
Password: my-password
(from sftp.users.conf file above)
Port: 2222
Ensure the env_files
listed in docker-compose.yml
are actually available in the config/
folder.
This is possibly due to missing config/sftp.users.conf
file on first run, which caused the SFTP image to create wrong upload folder. If you get this on a fresh install and don't mind deleting containers, a quick fix is to simply delete all containers and volumes related to Shiny, then ensure the config file is present, and start the whole thing again.
Possibly due to wrong owner of /upload/ folder. On a running Shiny Docker server, try:
docker exec -it shiny_shiny_1 chown 1001:www-data /srv/shiny-server/apps