Created
September 29, 2021 14:48
-
-
Save amanjuman/77a781b10fd819f3ebcc9a2b7205a0b1 to your computer and use it in GitHub Desktop.
Shiny RStudio Nginx Reverse Proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server | |
{ | |
# Listen | |
listen 80; | |
listen [::]:80; | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
# Directory & Server Naming | |
server_name fqdn.domain.tld; | |
# HTTP to HTTPS redirection | |
if ($scheme != "https") | |
{ | |
return 301 https://$host$request_uri; | |
} | |
# SSL | |
ssl_certificate /etc/letsencrypt/live/fqdn.domain.tld/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/fqdn.domain.tld/privkey.pem; | |
ssl_trusted_certificate /etc/letsencrypt/live/fqdn.domain.tld/fullchain.pem; | |
## Shiny Server | |
location /shiny/ | |
{ | |
proxy_pass http://127.0.0.1:3838/; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
rewrite ^(/shiny/[^/]+)$ $1/ permanent; | |
proxy_connect_timeout 3h; | |
proxy_send_timeout 3h; | |
proxy_read_timeout 3h; | |
} | |
## RStudio | |
location /rstudio/ | |
{ | |
proxy_pass http://127.0.0.1:8787/; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_connect_timeout 3h; | |
proxy_send_timeout 3h; | |
proxy_read_timeout 3h; | |
} | |
# Disable Hidden FIle Access Except Lets Encrypt Verification | |
location ~ /\.well-known | |
{ | |
allow all; | |
} | |
# Nginx Logging | |
access_log /var/log/nginx/fqdn.domain.tld-access.log; | |
error_log /var/log/nginx/fqdn.domain.tld-error.log warn; | |
# Max Upload Size | |
client_max_body_size 100M; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment