Reverse Proxy 本地的 443-> 8888  (Access Jupyter)

Reverse Proxy 本地的 443-> 8888  (Access Jupyter) 的 nginx 設置

upstream notebook {
    server localhost:8888;
}
server {
    server_name jupyter.example.com 192.168.31.10;
    listen 80;
    listen 443 ssl;
    #rewrite ^/(.*) https://192.168.31.10/$1 permanent;
    ssl_certificate /etc/pki/tls/certs/cert.pem;
    ssl_certificate_key /etc/pki/tls/private/key.pem;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;

    location / {
        proxy_pass http://notebook;
        proxy_set_header origin  "http://127.0.0.1:8888";
        proxy_set_header host    "127.0.0.1:8888";
        proxy_set_header X-Real-IP "127.0.0.1";
    }

    location ~ /api/kernels/ {
        proxy_pass http://notebook;
        proxy_set_header origin  "http://127.0.0.1:8888";
        proxy_set_header host    "127.0.0.1:8888";
        proxy_set_header X-Real-IP "127.0.0.1";
        # WebSocket proxying
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    location ~ /terminals/ {
        proxy_pass http://notebook;
        proxy_set_header origin  "http://127.0.0.1:8888";
        proxy_set_header host    "127.0.0.1:8888";
        proxy_set_header X-Real-IP "127.0.0.1";
        # WebSocket proxying
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

}

如果在環境中有開啟 selinux, 別忘了加上 port 的端口,不然會 Permission Denied.

 # semanage port -a -t http_port_t -p tcp 8888

 

Author: jerryw1974

learning and focus on computer science, cloud infrastructure, virtualization and information security, technical, networking,platform system and cyber-security related topic.