docker 中nginx 和jupyter 如何反向代理
nginx 使用 docker.io/richarvey/nginx-php-fpm:latest , 配置在 /etc/nginx/sites-enables
jupyter 使用 docker.io/tensorflow/tensorflow:latest 配置在 ~/.jupyter 目录 ip 172.17.0.7
解决wss的错误
$proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
nginx 配置 |
server{ listen 443 ssl; server_name localhost; root /var/www/html; index index.html index.htm index.php; keepalive_timeout 70; server_tokens off; ssl on; ssl_certificate /etc/nginx/ssl/server.crt; ssl_certificate_key /etc/nginx/ssl/server.key; ssl_client_certificate /etc/nginx/ssl/ca-chain.cert.pem; ssl_verify_client off; location ^~/ju { proxy_pass http://172.17.0.7:8888/ju; #以下是一些反向代理的配置可删除 proxy_redirect off; #后端的Web服务器可以通过X-Forwarded-For获取用户真实IP proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; client_max_body_size 10m; #允许客户端请求的最大单文件字节数 client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数 proxy_connect_timeout 300; #nginx跟后端服务器连接超时时间(代理连接超时) proxy_send_timeout 300; #后端服务器数据回传时间(代理发送超时) proxy_read_timeout 300; #连接成功后,后端服务器响应时间(代理接收超时) proxy_buffer_size 4k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小 proxy_buffers 4 32k; #proxy_buffers缓冲区,网页平均在32k以下的话,这样设置 proxy_busy_buffers_size 64k; #高负荷下缓冲大小(proxy_buffers*2) proxy_temp_file_write_size 64k; } location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ =404; } error_page 404 /404.html; location = /404.html { root /var/www/errors; internal; } location ^~ /sad.svg { alias /var/www/errors/sad.svg; access_log off; } location ^~ /twitter.svg { alias /var/www/errors/twitter.svg; access_log off; } location ^~ /gitlab.svg { alias /var/www/errors/gitlab.svg; access_log off; } # pass the PHP scripts to FastCGI server listening on socket # location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_index index.php; include fastcgi_params; } location ~* \.(jpg|jpeg|gif|png|css|js|ico|webp|tiff|ttf|svg)$ { expires 5d; } # deny access to . files, for security # location ~ /\. { log_not_found off; deny all; } location ^~ /.well-known { allow all; auth_basic off; } } |
import os from IPython.lib import passwd c = c # pylint:disable=undefined-variable c.NotebookApp.ip = '0.0.0.0' # https://github.com/jupyter/notebook/issues/3946 c.NotebookApp.port = int(os.getenv('PORT', 8888)) c.NotebookApp.open_browser = False # sets a password if PASSWORD is set in the environment if 'PASSWORD' in os.environ: password = os.environ['PASSWORD'] if password: c.NotebookApp.password = passwd(password) else: c.NotebookApp.password = '' c.NotebookApp.token = '' del os.environ['PASSWORD'] c.NotebookApp.base_project_url = '/ju' c.NotebookApp.base_url ='/ju' |