Skip to content

Instantly share code, notes, and snippets.

@hermes-pimentel
Last active September 16, 2017 15:13
Show Gist options
  • Save hermes-pimentel/7cea37a0b9262a7bfb6771c89686ea1c to your computer and use it in GitHub Desktop.
Save hermes-pimentel/7cea37a0b9262a7bfb6771c89686ea1c to your computer and use it in GitHub Desktop.
Jupyter Notebook Ngnix Proxy Config Working.
# Jupyter configuration #
c.NotebookApp.open_browser = False
c.NotebookApp.port = 9090
c.NotebookApp.password = u'sha1:somepass'
c.Authenticator.admin_users = {'hadoop'}
c.LocalAuthenticator.create_system_users = True
c.NotebookApp.contents_manager_class = 's3contents.S3ContentsManager'
c.S3ContentsManager.bucket_name = 'my-bucket'
c.S3ContentsManager.prefix = 'notebooks'
##### Jupyter service config #####
[root ~]# cat /etc/init/jupyter.conf
# jupyter
description "Jupyter"
start on runlevel [2345]
stop on runlevel [016]
respawn
respawn limit 0 10
console output
chdir /home/hadoop
script
sudo su - hadoop > /var/log/jupyter/jupyter.log 2>&1 <<BASH_SCRIPT
export NODE_PATH="/usr/lib/node_modules"
export PYSPARK_DRIVER_PYTHON="jupyter"
export PYSPARK_DRIVER_PYTHON_OPTS="notebook --no-browser --log-level=INFO"
export NOTEBOOK_DIR="s3://my-bucket/notebooks/"
pyspark
BASH_SCRIPT
end script
########
#### Ngnix configuration for notebook running on localhost:9090 port ####
user nginx; ## Default: nobody
worker_processes 5; ## Default: 1
error_log /mnt/var/log/nginx-error.log;
worker_rlimit_nofile 8192;
events {
worker_connections 4096; ## Default: 1024
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream notebook {
server localhost:9090;
}
server{
listen 8888;
server_name _ ;
location / {
proxy_pass http://notebook;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Origin "";
}
location ~* /(api/kernels/[^/]+/(channels|iopub|shell|stdin)|terminals/websocket)/? {
proxy_pass http://notebook;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 86400;
proxy_set_header Origin "";
proxy_buffering off;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment