-
Notifications
You must be signed in to change notification settings - Fork 0
/
on-jupyter-server-start.sh
26 lines (19 loc) · 1.4 KB
/
on-jupyter-server-start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# This script configures proxy settings for your Jupyter Server and Kernel appliations
# This is useful for use cases where you would like to configure your notebook instance in your custom VPC
# without direct internet access to route all traffic via a proxy server in your VPC.
# Please ensure that you have already configure a proxy server in your VPC.
#!/bin/bash
set -eux
# PARAMETERS
PROXY_SERVER=http://proxy.local:3128
# Please note that we are excluding S3 because we do not want this traffic to be routed over the public internet, but rather through the S3 endpoint in the VPC.
EXCLUDED_HOSTS="s3.amazonaws.com,127.0.0.1,localhost"
mkdir -p ~/.ipython/profile_default/startup/
touch ~/.ipython/profile_default/startup/00-startup.py
echo "export http_proxy='$PROXY_SERVER'" | tee -a ~/.profile >/dev/null
echo "export https_proxy='$PROXY_SERVER'" | tee -a ~/.profile >/dev/null
echo "export no_proxy='$EXCLUDED_HOSTS'" | tee -a ~/.profile >/dev/null
echo "import sys,os,os.path" | tee -a ~/.ipython/profile_default/startup/00-startup.py >/dev/null
echo "os.environ['HTTP_PROXY']="\""$PROXY_SERVER"\""" | tee -a ~/.ipython/profile_default/startup/00-startup.py >/dev/null
echo "os.environ['HTTPS_PROXY']="\""$PROXY_SERVER"\""" | tee -a ~/.ipython/profile_default/startup/00-startup.py >/dev/null
echo "os.environ['NO_PROXY']="\""$EXCLUDED_HOSTS"\""" | tee -a ~/.ipython/profile_default/startup/00-startup.py >/dev/null