Shinyproxy: Using app_direct and redirect to https

Created on 9 Nov 2020  ·  12Comments  ·  Source: openanalytics/shinyproxy

Hello,

I'm using app_direct functionnality and want to redirect http to https, everything works fine except when I use :

https://www.mycompany.com

it redirect me to :

http://www.mycompany.com/app_direct/myapp

Without https.

My Nginx config is:

server {
  listen                80;
  server_name           mycompany.com www.mycompany.com;
  rewrite     ^(.*)     https://$server_name$1 permanent;
  # return 301 https://$server_name$request_uri;
}


server {
  listen                443 ssl;
  server_name           mycompany.com www.mycompany.com;
  access_log            /var/log/nginx/shinyproxy.access.log;
  error_log             /var/log/nginx/shinyproxy.error.log error;

  ssl on;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

  ssl_certificate       /etc/ssl/certs/mycompany.cert;
  ssl_certificate_key   /etc/ssl/private/mycompany.key;

   location / {
       proxy_pass          http://127.0.0.1:3838/;

       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       proxy_read_timeout 600s;

       proxy_redirect    off;
       proxy_set_header  Host             $http_host;
       proxy_set_header  X-Real-IP        $remote_addr;
       proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
       proxy_set_header  X-Forwarded-Protocol $scheme;
     }

}

Is there something bad in my config ?

Thanks for your help.

Victor

enhancement

Most helpful comment

I found that fix on another thread as well, when I noticed that this Spring config does not exist,
And yes -

server:
  forward-headers-strategy: "native"

is the fix here!

All 12 comments

same config, same problem, causing impossible login via active directory

Hi @pvictor

I just tested this setup on an internal setup, and the redirect is working fine.
Are you sure you have the following code in your application.yaml:

server:
  useForwardHeaders: true
   proxy_set_header  X-Forwarded-Protocol $scheme;

I think changing $scheme here to https might help

Hi,

it seems like the setting
```
server:
useForwardHeaders: true
````
is not working on shinyproxy 2.4.1 any more. We have upgraded from shinyproxy 2.3.0 where it was working fine.

Hi @egde

You could be right! We updated Spring in ShinyProxy 2.4.0 and they seem to have changed the property name.
Can you please try with:

server:
   forward-headers-strategy: native

If that doesn't work (correctly), you can also try:

server:
   forward-headers-strategy: framework

Please share your results, I'm looking forward to them!

I found that fix on another thread as well, when I noticed that this Spring config does not exist,
And yes -

server:
  forward-headers-strategy: "native"

is the fix here!

Very nice! Thanks for reporting back!

@pvictor @danielfm123 please try this fix too.

Thanks! it fixes the login but breaks ajax for DT
DataTables warning: table id=DataTables_Table_0 - Ajax error. For more information about this error, please see http://datatables.net/tn/7

Exactly! That error I have as well

image

Do you both have logging set to debug level? If so, please apply the change mentioned here https://github.com/openanalytics/shinyproxy/issues/246#issuecomment-719455644

Logging was not set at Debug anywhere. Initially it was at

logging:
  level:
    root: INFO

I tried the suggested config as above. It did not help.
More details in the other issue #246

Documentation relating to the original issue is updated. Let's handle the other issue in #246.

I'll lock this issue, so that the issues stay maintainable for us.
Of course, as always don't hesitate to open a new issue if you encounter any problem!

Was this page helpful?
0 / 5 - 0 ratings