File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ location = /rstudio {
50
50
location /rstudio/ {
51
51
rewrite ^/rstudio/(.*)$ /$1 break;
52
52
# Standard RStudio/NGINX configuration
53
- proxy_pass http://127.0.0.1 :8787;
53
+ proxy_pass http://localhost :8787;
54
54
proxy_http_version 1.1;
55
55
proxy_set_header Upgrade $http_upgrade;
56
56
proxy_set_header Connection $connection_upgrade;
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ location = / {
77
77
location /rstudio/ {
78
78
rewrite ^/rstudio/(.*)$ /$1 break;
79
79
# Standard RStudio/NGINX configuration
80
- proxy_pass http://127.0.0.1 :8787;
80
+ proxy_pass http://localhost :8787;
81
81
proxy_http_version 1.1;
82
82
proxy_set_header Upgrade $http_upgrade;
83
83
proxy_set_header Connection $connection_upgrade;
Original file line number Diff line number Diff line change @@ -46,6 +46,30 @@ def _support_arg(arg):
46
46
ret = subprocess .check_output ([get_rstudio_executable ('rserver' ), '--help' ])
47
47
return ret .decode ().find (arg ) != - 1
48
48
49
+ def detect_env ():
50
+ import socket
51
+ supports_ipv4 = supports_ipv6 = False
52
+ try :
53
+ with socket .socket (socket .AF_INET , socket .SOCK_STREAM ) as s :
54
+ s .bind (('127.0.0.1' , 0 ))
55
+ supports_ipv4 = True
56
+ except OSError :
57
+ pass
58
+ try :
59
+ with socket .socket (socket .AF_INET6 , socket .SOCK_STREAM ) as s :
60
+ s .bind (('::1' , 0 ))
61
+ supports_ipv6 = True
62
+ except OSError :
63
+ pass
64
+ if supports_ipv4 and supports_ipv6 :
65
+ return '::' # Dual-stack
66
+ elif supports_ipv6 :
67
+ return '::'
68
+ elif supports_ipv4 :
69
+ return '0.0.0.0'
70
+ else :
71
+ raise EnvironmentError ('No IPv4 or IPv6 support detected.' )
72
+
49
73
def _get_cmd (port ):
50
74
ntf = tempfile .NamedTemporaryFile ()
51
75
@@ -60,7 +84,7 @@ def _get_cmd(port):
60
84
'--server-working-dir=' + os .getenv ('HOME' ),
61
85
'--auth-none=1' ,
62
86
'--www-frame-origin=same' ,
63
- # '--www-address=0.0.0.0' ,
87
+ '--www-address=' + detect_env () ,
64
88
'--www-port=' + str (port ),
65
89
'--www-verify-user-agent=0' ,
66
90
'--rsession-which-r=' + get_rstudio_executable ('R' ),
You can’t perform that action at this time.
0 commit comments