jupyter / tmpnb

Creates temporary Jupyter Notebook servers using Docker containers. [DEPRECATED - See BinderHub project]
https://github.com/jupyterhub/binderhub
BSD 3-Clause "New" or "Revised" License
528 stars 123 forks source link

Run HTTP-Proxy on Port 80? #253

Closed rwmajor2 closed 7 years ago

rwmajor2 commented 7 years ago

I am pretty new to some of this. What is the quickest way to spin up the proxy on Port 80 vs. the default 8000?

Thanks.

minrk commented 7 years ago

The quickest way is probably:

python orchestrate.py --port=80
rwmajor2 commented 7 years ago

Thanks @minrk. Bare with me, as I am new to this project. So far, I have basically done the basics on an Ubuntu 14 host in AWS.

docker pull jupyter/minimal-notebook export TOKEN=$( head -c 30 /dev/urandom | xxd -p ) docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN --name=proxy jupyter/configurable-http-proxy --default-target http://127.0.0.1:9999 docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN --name=tmpnb -v /var/run/docker.sock:/docker.sock jupyter/tmpnb

This gets me up and running easy on port 8000.

When you say to run python orchestrate.py --port=80, I am not sure where I run that from. If you could provide a little more guidance, I would greatly appreciate it.

rgbkrk commented 7 years ago

The proxy is run separately with tmpnb, you'll need to set the port there:

docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN \
  --name=proxy jupyter/configurable-http-proxy \
  --default-target http://127.0.0.1:9999 \
  --port 80

However, to do that you'd need to change options on tmpnb itself which I don't think are exposed... It would look something like:

docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN \
  --name=tmpnb \
  -v /var/run/docker.sock:/docker.sock jupyter/tmpnb \
  python orchestrate.py --proxy-port 80
rwmajor2 commented 7 years ago

When I attempt:

docker run --net=host -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN  --name=proxy jupyter/configurable-http-proxy  --default-target http://127.0.0.1:9999  --port 80

it throws an error and the container doesn't start:

13:19:34.157 - info: [ConfigProxy] Proxying http://*:80 to http://127.0.0.1:9999
13:19:34.161 - info: [ConfigProxy] Proxy API at http://localhost:81/api/routes
events.js:154
      throw er; // Unhandled 'error' event
      ^

Error: listen EACCES 0.0.0.0:80
    at Object.exports._errnoException (util.js:890:11)
    at exports._exceptionWithHostPort (util.js:913:20)
    at Server._listen2 (net.js:1221:19)
    at listen (net.js:1270:10)
    at Server.listen (net.js:1366:5)
    at Object. (/usr/local/lib/node_modules/configurable-http-proxy/bin/configurable-http-proxy:191:20)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
minrk commented 7 years ago

You need root permissions to listen on port 80, normally, and CHP isn't run as root. You could run the proxy without --net=host and use docker to expose port 80: docker run -p 80:8000 .... You would need to use docker networks, as covered in #258 in order for everything to talk to each other:

docker network create tmpnb
docker run --network=tmpnb -p 80:8000 -d \
    -e CONFIGPROXY_AUTH_TOKEN=$TOKEN  \
    --name=proxy \
    jupyter/configurable-http-proxy \
        --default-target http://tmpnb:9999 \
        --api-ip=0.0.0.0
docker run --network=tmpnb -d \
    -e CONFIGPROXY_AUTH_TOKEN=$TOKEN \
    -e CONFIGPROXY_ENDPOINT=http://proxy:8001 \
    --name tmpnb \
    jupyter/tmpnb python orchestrate.py \
        --docker_network=tmpnb

Alternately, you could run the proxy outside docker.

eldos-dl commented 7 years ago
docker network create tmpnb

docker run --network=tmpnb -p 80:8000 -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN --name=proxy jupyter/configurable-http-proxy --default-target http://tmpnb:9999 --api-ip=0.0.0.0

docker run --network=tmpnb -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN -e CONFIGPROXY_ENDPOINT=http://proxy:8001 -v /var/run/docker.sock:/docker.sock --name tmpnb jupyter/tmpnb python orchestrate.py --docker_network=tmpnb --container-user=jovyan --command='jupyter notebook --no-browser --port {port} --ip=0.0.0.0 --NotebookApp.base_url=/{base_path} --NotebookApp.port_retries=0 --NotebookApp.token="" --NotebookApp.disable_check_xsrf=True'
tanmaybaranwal commented 7 years ago
docker network create tmpnb

export TOKEN=$( head -c 30 /dev/urandom | xxd -p )

docker run --network=tmpnb -p 80:8000 -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN --name=proxy jupyter/configurable-http-proxy --default-target http://tmpnb:9999 --api-ip=0.0.0.0

docker run --network=tmpnb -d -e CONFIGPROXY_AUTH_TOKEN=$TOKEN -e CONFIGPROXY_ENDPOINT=http://proxy:8001 -v /var/run/docker.sock:/docker.sock --name tmpnb jupyter/tmpnb python orchestrate.py --docker_network=tmpnb --container-user=jovyan --command='jupyter notebook --no-browser --port {port} --ip=0.0.0.0 --NotebookApp.base_url=/{base_path} --NotebookApp.port_retries=0 --NotebookApp.token="" --NotebookApp.disable_check_xsrf=True'
rwmajor2 commented 7 years ago

Thanks.