Last active
February 25, 2022 08:47
-
-
Save magic-lantern/1b5e11c3cf5964b69e8e7824df015c5d to your computer and use it in GitHub Desktop.
Nginx Configuration for HTTPS RStudio Server reverse proxy
This file contains 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
## | |
# Customized Nginx configuration | |
## | |
server { | |
root /var/www/html; | |
index index.html index.htm index.nginx-debian.html; | |
server_name rstudio.learnclinicaldatascience.org; # managed by Certbot | |
access_log /var/log/nginx/rstudio.learnclinicaldatascience.org; | |
location / { | |
proxy_set_header Host $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; | |
proxy_http_version 1.1; | |
# have to add http_upgrade lines to /etc/nginx/nginx.conf for these next 2 lines to work | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
proxy_read_timeout 7d; | |
# Fix the “It appears that your reverse proxy set up is broken" error. | |
proxy_pass http://localhost:8787; | |
proxy_redirect http://localhost:8787 $scheme://$http_host/; | |
} | |
listen [::]:443 ssl ipv6only=on; # managed by Certbot | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/rstudio.learnclinicaldatascience.org/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/rstudio.learnclinicaldatascience.org/privkey.pem; # managed by Certbot | |
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | |
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | |
} | |
server { | |
if ($host = rstudio.learnclinicaldatascience.org) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
listen 80 ; | |
listen [::]:80 ; | |
server_name rstudio.learnclinicaldatascience.org; | |
return 404; # managed by Certbot | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment