3

We are trying to update our internal server infrastructure and to proxy all accesses to our R shiny webservers through an Nginx server. Im able to get a response from the shiny server but Im not able to get related files like css/js through the Nginx server.

Setup:

  • 2 docker container (1 for hosting nginx, 1 running R for a shiny application)

  • both docker container are members of an docker network

  • shiny server listens to port 7676 (internal ip-adress 172.18.0.3)

  • nginx server is hosting few static html files with iFrames (legacy, cant get ride off), which should show content of the shiny server

  • accessing nginx-server/QueryLandscape.html loads the page with the iFrame <iframe src="ilandscape"></iframe>

  • iFrame works: it loads the static part of R-shiny application, but it doesnt load the related JS/CSS/....(e.g. http://nginx-server:8001/ilandscape/shared/shiny.css)

  • within the nginx-docker container i can access this css file wget 172.18.0.3:7676/shared/shiny.css

Nginx.conf

location /ilandscape/ {
    proxy_pass http://172.18.0.3:7676/;
    #proxy_redirect http://172.18.0.3:7676/ $scheme://$host/;

    # websocket headers
    proxy_set_header Upgrade $http_upgrade;

    proxy_http_version 1.1;
    proxy_read_timeout 20d;
    proxy_set_header Host $host;
}

What am I missing in my nginx conf to proxy/redirect http://nginx-server:8001/ilandscape/shared/shiny.css --> 172.18.0.3:7676/shared/shiny.css ?

Thanks for your help, Tobi

tkschmidt
  • 79
  • 1
  • 8

1 Answers1

0

Looks like the iframes acting as a browser are receiving the hostname instead of the full path to the resources. Can you set up the following ReverseProxy headers and give it a go:

proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Basically you have a proxy at the moment, and we want a reverse proxy too. Let me know if this works.

Neekoy
  • 2,325
  • 5
  • 29
  • 48