I have a weird issue where nginx
"starts too soon?" when the server boots up, nginx
loads before rstudio-server
has been loaded, which causes a "502 Bad gateway" error when I try to access the server using the reverse proxy (e.g http://server_ip/rstudio
) even if rstudio-server
is running by the time I try to access it (I can confirm this by using the 8787 port instead of /rstudio
). This only happens with rstudio-server
. shiny-server
running on the same server and behind the same port works normally. Also, I'm using the RStudio's recommended configuration for nginx
As a workaround I have modified this systemd
file for nginx
: /etc/systemd/system/multi-user.target.wants/nginx.service
to include this line After=network-online.target nss-lookup.target
which "solves" the problem but this is obviously not a definitive solution since a system update could replace this file breaking the fix.
Does this has happened to any of you, and have you found a more robust solution?
Also, a curious thing, even with the fix in place, when the reverse proxy is working "normally", I get a lot of error messages in the nginx
error log while the rstudio-server
login screen is active and stops once you log-in
For example
2022/08/26 11:17:52 [error] 906#906: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.15, server: test_server, request: "GET /rstudio/ HTTP/1.1", upstream: "http://[::1]:8787/", host: "192.168.0.101"
2022/08/26 11:17:52 [error] 907#907: *11 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.15, server: test_server, request: "GET /rstudio/js/signin.js HTTP/1.1", upstream: "http://[::1]:8787/js/signin.js", host: "192.168.0.101", referrer: "http://192.168.0.101/rstudio/auth-sign-in?appUri=%2F"
2022/08/26 11:43:01 [error] 482#482: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.15, server: test_server, request: "GET /rstudio/ HTTP/1.1", upstream: "http://[::1]:8787/", host: "192.168.0.101"
2022/08/26 11:43:13 [error] 858#858: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.15, server: test_server, request: "GET /rstudio/ HTTP/1.1", upstream: "http://[::1]:8787/", host: "192.168.0.101"
2022/08/26 11:43:25 [error] 858#858: *11 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.15, server: test_server, request: "GET /rstudio/ HTTP/1.1", upstream: "http://[::1]:8787/", host: "192.168.0.101", referrer: "http://192.168.0.101/rstudio/auth-sign-in?appUri=%2F"
2022/08/26 11:57:33 [error] 858#858: *54 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.15, server: test_server, request: "GET /rstudio/rstudio.css HTTP/1.1", upstream: "http://[::1]:8787/rstudio.css", host: "192.168.0.101", referrer: "http://192.168.0.101/rstudio/auth-sign-in?appUri=%2F"
2022/08/26 11:57:33 [error] 860#860: *62 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.15, server: test_server, request: "GET /rstudio/js/signin.js HTTP/1.1", upstream: "http://[::1]:8787/js/signin.js", host: "192.168.0.101", referrer: "http://192.168.0.101/rstudio/auth-sign-in?appUri=%2F"
2022/08/26 11:57:33 [error] 861#861: *60 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.15, server: test_server, request: "GET /rstudio/signin.css HTTP/1.1", upstream: "http://[::1]:8787/signin.css", host: "192.168.0.101", referrer: "http://192.168.0.101/rstudio/auth-sign-in?appUri=%2F"