thomst08 / requestrr

Requestrr is a chatbot used to simplify using services like Sonarr/Radarr/Ombi via the use of chat. Current platform is Discord only, but the bot was built around the ideology of quick adaptation for new features as well as new platforms.
MIT License
185 stars 13 forks source link

No longer works behind nginx with a base path #38

Open Znuff opened 2 months ago

Znuff commented 2 months ago

I've upgraded from v2.1.3 (last release under darkalfx/requestrr), to 2.1.6 here, and our reverse proxy configuration no longer works.

I'm using a base path of /requestrr:

  "Port": 4545,
  "BaseUrl": "/requestrr",
  "DisableAuthentication": true,

And I handle the auth via Organizr.

Previously this configuration worked simply as:

    # ...
    proxy_set_header Host $host;
    proxy_redirect  http://  $scheme://;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    proxy_cache_bypass $cookie_session;
    proxy_no_cache $cookie_session;

    # ...

    location /requestrr {
      # auth_request /organizr-auth/0;

      proxy_pass http://10.242.6.109:4545/requestrr;
    }

Now when I access https://.../requestrr I get an infinite redirect loop, which looks like:

chrome_6UvVKL8rWM

This still works correctly while accessing http://10.242.6.109:4545/requestrr, it's just the reverse proxy not working anymore, which worked fine on 2.1.3/2.1.2

Seems that the requests are not properly using the basepath, for some reasons.

thomst08 commented 2 months ago

Hey @Znuff,

Thanks for reaching out, hmmmm. There shouldn't be any major changes that affect this, but it might have something to do with the original changes I made with the webapp. I haven't got any answers for you atm as it should be working, but, checked out closed issue #34, it was regarding proxy and SSL, might be worth looking to see if there is something there. I will see what I can do and get back to you when I find something.

edrock200 commented 2 months ago

Have you tried it without the /requestrr on the proxy pass @Znuff

Znuff commented 2 months ago

Yes I have tried that. Didn't really change much. Still loops.

thomst08 commented 1 month ago

I have emulated your issue in a virtual environment, I think I understand what is happening here. I will work out a solution and release a build when I have corrected the issue, I will keep you posted.

thomst08 commented 1 month ago

Hey @Znuff,

I have been working on the issue and tweaked some things and tested them. I found some issues but they only seem to be affecting me when in a development environment as production builds don't have the same problem.

I did manage to get the app working correctly however through the proxy, and using the current version. I tried to match your Nginx setup with the info you gave me, this is the setup I ended up with, the biggest thing was I needed redirection to be off as it was blocking and redirecting the API calls, this matches the errors you are showing.

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name requestrr.example.com;

  ssl_certificate /etc/nginx/ssl/example.com/fullchain.pem;
  ssl_certificate_key /etc/nginx/ssl/example.com/key.pem;

  client_max_body_size 40M;
  server_tokens off;
  proxy_http_version 1.1;
  proxy_cache_bypass $cookie_session;
  proxy_no_cache $cookie_session;

  location /requestrr {
    proxy_pass http://127.0.0.1:4545/requestrr;
    proxy_redirect off;

    proxy_set_header Host $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-Proto $scheme;
    proxy_set_header X-Forwarded-Protocol $scheme;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }

  location ~ /\.ht {
    deny all;
  }
}

With your setup you are redirecting, I am thinking this is causing it to redirect to the root and reloading the main page, giving you the reloading issue. Let me know if this helps.