Skip to content

Instantly share code, notes, and snippets.

@psychemedia
Last active February 4, 2020 15:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psychemedia/d72b396c491fe1348bc1d9badfdcce81 to your computer and use it in GitHub Desktop.
Save psychemedia/d72b396c491fe1348bc1d9badfdcce81 to your computer and use it in GitHub Desktop.
Simple docker-compose script for running OpenRefine, Jupyter notebook and postgres
server {
listen 80;
auth_basic Protected...;
auth_basic_user_file /etc/nginx/.htpasswd;
location / {
root /var/www/html ;
index index.html;
auth_basic off;
}
}
server {
listen 80;
auth_basic Protected...;
auth_basic_user_file /etc/nginx/.htpasswd;
location / {
root /var/www/html ;
index index.html;
auth_basic off;
}
location /openrefine/ {
proxy_pass http://127.0.0.1:3333/;
}
#https://nathan.vertile.com/blog/2017/12/07/run-jupyter-notebook-behind-a-nginx-reverse-proxy-subpath/
#Also requires a tweak to nginx.conf via /etc/nginx/conf.d and jupyter_notebook_confiig.py
location = /notebook {
rewrite ^/(.*)$ $1/ permanent;
}
location /notebook {
error_page 403 = @proxy_notebook;
deny 127.0.0.1;
allow all;
# set a webroot, if there is one
root /some-webroot;
try_files $uri @proxy_notebook;
}
location @proxy_notebook {
#rewrite /notebook(.*) $1 break;
proxy_read_timeout 300s;
proxy_pass http://upstream_notebook;
# pass some extra stuff to the backend
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ /notebook/api/kernels/ {
proxy_pass http://upstream_notebook;
proxy_set_header Host $host;
# websocket support
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
proxy_read_timeout 86400;
}
location ~ /notebook/terminals/ {
proxy_pass http://upstream_notebook;
proxy_set_header Host $host;
# websocket support
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
proxy_read_timeout 86400;
}
}
#!/bin/bash
GIST=d72b396c491fe1348bc1d9badfdcce81
git clone https://gist.github.com/$GIST.git
cd $GIST
source run.sh
#Based on: https://github.com/khezen/compose-postgres
version: '3.5'
services:
refine:
container_name: refine_container
image: psychemedia/openrefinedemo
ports:
- "3333:3333"
networks:
- refinet
restart: unless-stopped
jupyter:
container_name: refine_jupyter_notebook_container
image: jupyter/minimal-notebook
environment:
JUPYTER_TOKEN: 'letmein'
# --NotebookApp.token='' --NotebookApp.password=''
ports:
- "8888:8888"
volumes:
- ${PWD}/jupyter_notebook_config.py:/home/jovyan/.jupyter/jupyter_notebook_config.py
networks:
- refinet
restart: unless-stopped
networks:
refinet:
driver: bridge
<html>
<meta http-equiv="refresh" content="5" >
<head><title>Workbenche Online</title></head>
<body>
<h1>Workbenches Online</h1>
<p>Waiting for services to arrive...</p>
</body>
</html>
<html>
<head><title>Workbenches Online</title></head>
<body>
<h1>BYOS Workbenches Online</h1>
<div>THe following servers are available (single auth to access them all):
<ul>
<li><a href="./openrefine">OpenRefine server</a> </li>
<li><a href="./notebook">Jupyter notebook server</a></li>
</ul>
</div>
</body>
</html>
#Disable auth - rely on the nginx proxy
c.NotebookApp.token=''
c.NotebookApp.password=''
#For nginx proxy
c.NotebookApp.allow_origin = '*'
c.NotebookApp.base_url = '/notebook'
#/etc/nginx/conf.d/nginx_notebook.conf
upstream upstream_notebook {
server localhost:8888;
keepalive 32;
}
#!/bin/bash
USER_NAME=${USER_NAME:-test}
USER_PWD=${USER_PWD:-$USER_NAME}
apt-get update && apt-get install -y nginx apache2-utils
htpasswd -b -c /etc/nginx/.htpasswd $USER_NAME $USER_PWD
sudo ufw allow 'Nginx Full'
#Create a simple homepage
mkdir -p /var/www/html
mv index-load.html /var/www/html/index.html
mv default-base /etc/nginx/sites-available/default
#Get a minimal wev server running
nginx -s reload
#Install the docker containers
docker-compose up -d
#Copy over nginx settings for container services
mv nginx_notebook.conf /etc/nginx/conf.d/nginx_notebook.conf
mv default-full /etc/nginx/sites-available/default
#Refresh web page
mv index.html /var/www/html
#Reload nginx server
nginx -s reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment