Skip to content

Instantly share code, notes, and snippets.

@dreamorosi
Created February 5, 2020 13:15
Show Gist options
  • Save dreamorosi/a19b5e99df8755892ff87c05791726f1 to your computer and use it in GitHub Desktop.
Save dreamorosi/a19b5e99df8755892ff87c05791726f1 to your computer and use it in GitHub Desktop.
NGINX conf for Shiny App + RStudio + Preview (RunApp) with reverse proxy
# /etc/nginx/conf.d/shiny.conf
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name *.eu-west-1.compute.amazonaws.com;
location / {
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:3838;
proxy_http_version 1.1;
proxy_read_timeout 20d;
}
rewrite ^/rstudio$ $scheme://$http_host/rstudio/ permanent;
location /rstudio/ {
rewrite ^/rstudio/(.*)$ /$1 break;
proxy_pass http://localhost:8787;
proxy_redirect http://localhost:8787/ $scheme://$http_host/rstudio/;
proxy_http_version 1.1;
proxy_read_timeout 20d;
}
rewrite ^/preview$ $scheme://$http_host/preview/ permanent;
location /preview/ {
rewrite ^/preview/(.*)$ /$1 break;
proxy_pass http://localhost:1234;
proxy_redirect http://localhost:1234/ $scheme://$host/preview/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 20d;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment