Skip to content

Commit 0cf50dd

Browse files
Merge pull request #913 from jiridanek/jd_refactor_sync
[main] Reapply "RHOAIENG-17306, RHOAIENG-17307, RHOAIENG-17308: feat(workbenches): tolerate IPv6 environments in codeserver, jupyterlab and rstudio"
2 parents d954ab6 + ce326b0 commit 0cf50dd

File tree

12 files changed

+67
-16
lines changed

12 files changed

+67
-16
lines changed

codeserver/ubi9-python-3.11/nginx/api/kernels/access.cgi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ echo "Status: 200"
33
echo "Content-type: application/json"
44
echo
55
# Query the heartbeat endpoint
6-
HEALTHZ=$(curl -s http://127.0.0.1:8888/codeserver/healthz)
6+
HEALTHZ=$(curl -s http://localhost:8888/codeserver/healthz)
77
# Extract last_activity | remove milliseconds
88
LAST_ACTIVITY_EPOCH=$(echo $HEALTHZ | grep -Po 'lastHeartbeat":\K.*?(?=})' | awk '{ print substr( $0, 1, length($0)-3 ) }')
99
# Convert to ISO8601 date format

codeserver/ubi9-python-3.11/nginx/httpconf/http.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ map $http_x_forwarded_proto $custom_scheme {
3737
default $scheme;
3838
https https;
3939
}
40+
41+
###############
42+
# Dual-stack causes nginx to enable the "If a domain name resolves to several addresses, all of them will be used in a round-robin fashion." behavior
43+
# https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream_tries
44+
###############
45+
upstream workbench_server {
46+
server localhost:8787 max_fails=0;
47+
}
48+
###############

codeserver/ubi9-python-3.11/nginx/root/opt/app-root/nginxconf.sed

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Change port
22
/listen/s%80%8888 default_server%
33

4-
# Remove listening on IPv6
5-
/\[::\]/d
6-
74
# One worker only
85
/worker_processes/s%auto%1%
96

codeserver/ubi9-python-3.11/nginx/serverconf/proxy.conf.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ location = /codeserver {
4545

4646
location /codeserver/ {
4747
# Standard code-server/NGINX configuration
48-
proxy_pass http://127.0.0.1:8787/;
48+
proxy_pass http://workbench_server/;
4949
proxy_http_version 1.1;
5050
proxy_set_header Upgrade $http_upgrade;
5151
proxy_set_header Connection $connection_upgrade;

codeserver/ubi9-python-3.11/nginx/serverconf/proxy.conf.template_nbprefix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ location = / {
5959
location /codeserver/ {
6060
rewrite ^/codeserver/(.*)$ /$1 break;
6161
# Standard RStudio/NGINX configuration
62-
proxy_pass http://127.0.0.1:8787;
62+
proxy_pass http://workbench_server/;
6363
proxy_http_version 1.1;
64+
6465
proxy_set_header Upgrade $http_upgrade;
6566
proxy_set_header Connection $connection_upgrade;
6667
proxy_read_timeout 20d;

codeserver/ubi9-python-3.11/run-code-server.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,20 @@ if [ ! -d "$logs_dir" ]; then
110110
mkdir -p "$logs_dir"
111111
fi
112112

113+
# IPv6 support
114+
echo "Checking IPv6 support..."
115+
if [ -f /proc/net/if_inet6 ]; then
116+
BIND_ADDR="[::]:8787" # IPv6/dual-stack
117+
echo "IPv6 detected: binding to all interfaces (IPv4 + IPv6)"
118+
else
119+
BIND_ADDR="0.0.0.0:8787" # IPv4 only
120+
echo "IPv6 not detected: falling back to IPv4 only"
121+
fi
122+
113123
# Start server
114124
start_process /usr/bin/code-server \
115-
--bind-addr 0.0.0.0:8787 \
116-
--disable-telemetry \
117-
--auth none \
118-
--disable-update-check \
119-
/opt/app-root/src
125+
--bind-addr "${BIND_ADDR}" \
126+
--disable-telemetry \
127+
--auth none \
128+
--disable-update-check \
129+
/opt/app-root/src

jupyter/minimal/ubi9-python-3.11/start-notebook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ fi
3535

3636
# Start the JupyterLab notebook
3737
start_process jupyter lab ${NOTEBOOK_PROGRAM_ARGS} \
38-
--ServerApp.ip=0.0.0.0 \
38+
--ServerApp.ip="" \
3939
--ServerApp.allow_origin="*" \
4040
--ServerApp.open_browser=False

rstudio/c9s-python-3.11/nginx/httpconf/http.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ map $http_x_forwarded_proto $custom_scheme {
3737
default $scheme;
3838
https https;
3939
}
40+
41+
###############
42+
# Dual-stack causes nginx to enable the "If a domain name resolves to several addresses, all of them will be used in a round-robin fashion." behavior
43+
# https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream_tries
44+
###############
45+
upstream workbench_server {
46+
server localhost:8787 max_fails=0;
47+
}
48+
###############

rstudio/c9s-python-3.11/nginx/serverconf/proxy.conf.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ location = /rstudio {
5050
location /rstudio/ {
5151
rewrite ^/rstudio/(.*)$ /$1 break;
5252
# Standard RStudio/NGINX configuration
53-
proxy_pass http://127.0.0.1:8787;
53+
proxy_pass http://workbench_server/;
5454
proxy_http_version 1.1;
5555
proxy_set_header Upgrade $http_upgrade;
5656
proxy_set_header Connection $connection_upgrade;

rstudio/c9s-python-3.11/nginx/serverconf/proxy.conf.template_nbprefix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ location = / {
7777
location /rstudio/ {
7878
rewrite ^/rstudio/(.*)$ /$1 break;
7979
# Standard RStudio/NGINX configuration
80-
proxy_pass http://127.0.0.1:8787;
80+
proxy_pass http://workbench_server/;
8181
proxy_http_version 1.1;
8282
proxy_set_header Upgrade $http_upgrade;
8383
proxy_set_header Connection $connection_upgrade;

0 commit comments

Comments
 (0)