Skip to content

Instantly share code, notes, and snippets.

Last active Oct 26, 2018
What would you like to do?
Nginx Configuration for HTTPS RStudio Server reverse proxy
# Customized Nginx configuration
server {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name; # managed by Certbot
access_log /var/log/nginx/;
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/; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/; # 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 = {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
return 404; # managed by Certbot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment