<div dir="auto"><div>Hi,</div><div dir="auto"><br></div><div dir="auto">Does anyone have any suggestions about the below ?</div><div dir="auto"><br></div><div dir="auto">Thank you very much,</div><div dir="auto"><br></div><div dir="auto">Alison<br><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br>From: <strong class="gmail_sendername" dir="auto">Alison</strong> <span dir="auto"><<a href="mailto:alisonc1986@gmail.com">alisonc1986@gmail.com</a>></span><br>Date: Fri, 18 Jun 2021, 15:06<br>Subject: help websockets<br>To: <<a href="mailto:nginx@nginx.org">nginx@nginx.org</a>><br></div><br><br><div dir="ltr">Hi,<div><br></div><div>I'm using the following ingress in my jupyterhub application to expose the application externally from within the cluster:</div><div><br></div><div>################</div><div><br></div><div>apiVersion: <a href="http://networking.k8s.io/v1beta1" target="_blank" rel="noreferrer">networking.k8s.io/v1beta1</a><br>kind: Ingress<br>metadata:<br> name: py-ingress<br> annotations:<br> <a href="http://kubernetes.io/ingress.class" target="_blank" rel="noreferrer">kubernetes.io/ingress.class</a>: nginx<br> <a href="http://nginx.ingress.kubernetes.io/rewrite-target" target="_blank" rel="noreferrer">nginx.ingress.kubernetes.io/rewrite-target</a>: /jupyterhub$1$2<br> namespace: default<br>spec:<br> rules:<br> - http:<br> paths:<br> - path: /jupyterhub(/|$)(.*)<br> backend:<br> serviceName: jupyterhub<br> servicePort: 8888<br></div><div><br></div><div><br></div><div>#################</div><div><br></div><div><div dir="auto">When I deploy my application to one kubernetes cluster it works without problems.</div><div dir="auto"><br></div><div dir="auto">If I deploy the same application to another kubernetes cluster it fails (due to http 400 websockets). The part that fails is when I try from the Jupyter Notebook .... New ->Terminal ... or .... New -> Python3 kernel</div><div dir="auto"><br></div><div dir="auto">Any idea of what kind of additional annotations I need to add to the above ingress to solve the websocket issue ? </div><div dir="auto"><br></div><div dir="auto"><a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/" target="_blank" rel="noreferrer">https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/</a></div><div dir="auto"><br></div><div dir="auto">The nginx.conf content looks as follows for the application in both clusters<br></div><div><br></div><div>#########################</div><div><br></div><div>location ~* "^/jupyterhub(/|$)(.*)" {</div><div> set $namespace "default";</div><div> set $ingress_name "py-ingress";</div><div> set $service_name "";</div><div> set $service_port "";</div><div>set $location_path "/jupyterhub(/|$(literal_dollar))(.*)";</div><div><br></div><div> rewrite_by_lua_block {</div><div> lua_ingress_rewrite({</div><div> force_ssl_redirect = false,</div><div> ssl_redirect = true,</div><div> force_no_ssl_redirect = false,</div><div> use_port_in_redirects = false,</div><div> })</div><div> balancer.rewrite()</div><div> plugins.run()</div><div> }</div><div> </div><div> header_filter_by_lua_block {</div><div> lua_ingress.header()</div><div> plugins.run()</div><div> }</div><div> </div><div> body_filter_by_lua_block {</div><div> }</div><div><br></div><div> log_by_lua_block {</div><div> balacer.log()</div><div><br></div><div> monitor.call()</div><div><br></div><div> plugins.run()</div><div> }</div><div><br></div><div> port_in_redirect off;</div><div><br></div><div> set $balancer_ewma_score -1;</div><div> set $proxy_upstream_name "default-jupyterhub-8888";</div><div> set $proxy_host $proxy_upstream_name;</div><div> set $pass_access_scheme $scheme;</div><div> set $pass_server_port $server_port;</div><div> set $best_http_host $http_host;</div><div> set $pass_port $pass_server_port;</div><div> set $proxy_alternative_upstream_name "";</div><div> client_max_bosy_size 1m;</div><div> proxy_set_header Host $best_http_host;</div><div><br></div><div> # Allow websocket connections</div><div><br></div><div> proxy_set_header Upgrade $http_upgrade;</div><div> proxy_set_header Connection $connection_upgrade;</div><div> proxy_set_header X-Request-ID $req_id;</div><div> proxy_set_header X-Real-IP $remote_addr;</div><div> proxy_set_header X-Forwarded-For $remote_addr;</div><div> proxy_set_header X-Forwarded-Proto $pass_access_scheme;</div><div> proxy_set_header X-Forwarded-Host $best_http_host; <br></div><div> proxy_set_header X-Forwarded-Port $pass_port;</div><div> proxy_set_header X-Scheme $pass_access_scheme;</div><div> proxy_set_header X-Original-Forwarded-For $http_x_forwarded_for;</div><div></div><div> proxy_set_header Proxy</div><div> proxy_connect_timeout 5s;</div><div> proxy_send_timeout 60s;</div><div> proxy_buffering off;</div><div> proxy_buffer_size 4k;</div><div> proxy_buffers 4 4k;</div><div> proxy_max_temp_file_size 1024m;</div><div> proxy_request_buffering on;</div><div> proxy_http_version 1.1;</div><div> proxy_cookie_domain off;</div><div> proxy_cookie_path off;</div><div> proxy_next_upstream error timeout;</div><div> proxy_next_upstream_timeout 0;</div><div> proxy_next_upstream_tries 3;</div><div> </div><div> rewrite "(?i)/jupyterhub (/|$)(.*)" /jupyter$1$2 break;</div><div><br></div><div> proxy_pass <a href="http://upstream_balancer/" target="_blank" rel="noreferrer">http://upstream_balancer</a>;</div><div> </div><div> proxy_redirect off;</div><div><br></div><div>} </div><div> </div><div>##########################</div><div dir="auto"><br></div><div dir="auto">Thank you very much,</div></div><div><br></div><div>Alison</div></div>
</div></div></div>