Created
June 4, 2017 21:19
-
-
Save kylemcdonald/522c826e49c61c3e23ccc39055477a3d to your computer and use it in GitHub Desktop.
nginx config for port forwarding to a Jupyter instance on localhost.
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
user www-data; | |
worker_processes auto; | |
pid /run/nginx.pid; | |
## based on https://gist.github.com/cboettig/8643341bd3c93b62b5c2 | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
upstream jupyter { | |
server localhost:8888 fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name hands.art.cfa.cmu.edu; | |
rewrite ^ https://$host$request_uri? permanent; | |
} | |
server { | |
listen 443; | |
client_max_body_size 50M; | |
server_name hands.art.cfa.cmu.edu; | |
ssl on; | |
ssl_certificate /etc/letsencrypt/live/hands.art.cfa.cmu.edu/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/hands.art.cfa.cmu.edu/privkey.pem; | |
ssl_ciphers "AES128+EECDH:AES128+EDH"; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_prefer_server_ciphers on; | |
ssl_session_cache shared:SSL:10m; | |
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains"; | |
add_header X-Content-Type-Options nosniff; | |
ssl_stapling on; # Requires nginx >= 1.3.7 | |
ssl_stapling_verify on; # Requires nginx => 1.3.7 | |
resolver_timeout 5s; | |
location / { | |
proxy_pass http://jupyter; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} | |
location ~* /(api/kernels/[^/]+/(channels|iopub|shell|stdin)|terminals/websocket)/? { | |
proxy_pass http://jupyter; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
# WebSocket support | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice work!