Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: Can not use behind reverse proxy with path different root #365

Open
resetsa opened this issue Jan 30, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@resetsa
Copy link

resetsa commented Jan 30, 2025

I use v0.35.1 version as docker container.
And cannot use behind reverse proxy (NGINX), because many request used wrong URI.

My nginx config

   ...
    location /redlib/ {
        proxy_pass http://redlib:8080/;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_http_version 1.1;
    }
    ...

If I use this - all fine.

    location / {
        proxy_pass http://redlib:8080/;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_http_version 1.1;
    }

I want to use not root URI for proxying to redlib service.

Typical log from NGINX

2025/01/30 06:20:28 [error] 20#20: *19 open() "/var/www/thumb/b/H7a8FF_jgDIPQSCjUbKi1LouxlT1cWW3xDHkS8-Cvyo.jpg" failed (2: No such file or directory), client: xx.xx.xx.xx, server: xxx.xxx.xxx, request: "GET /thumb/b/H7a8FF_jgDIPQSCjUbKi1LouxlT1cWW3xDHkS8-Cvyo.jpg HTTP/1.1", host: "xxx.xxx.xxx" xx.xx.xx.xx - - [30/Jan/2025:06:20:28 +0000] "GET /thumb/b/H7a8FF_jgDIPQSCjUbKi1LouxlT1cWW3xDHkS8-Cvyo.jpg HTTP/1.1" 404 548 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/116.0.0.0" "-"

Screen with problem
Image

I tried to use FULL_URL but it not helped.

@resetsa resetsa added the bug Something isn't working label Jan 30, 2025
@ButteredCats
Copy link
Contributor

Redlib doesn't have any sort of option to support running under a subdirectory. The FULL_URL option is related to RSS feeds.

I'm not sure if you're aware of the reason running under a subdirectory breaks Redlib (and lots of other apps) but in case you aren't I'll try and explain it:
Within the HTML of the page any link to another resource, stuff like CSS, javascript, or images, starts with /. Take /style.css for example, this causes clients to request /style.css rather than /redlib/style.css and because /style.css is not within your /redlib/ block, NGINX attempts to serve the clients a local file which doesn't exist rather than using your proxy_pass to Redlib and that's why you see those open() errors in the log.

However, it may be possible to get this to work by using a rewrite https://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite

If possible I'd suggest using a subdomain instead of using a subdirectory, it's a lot easier. Even if you can start redirecting requests for / to /redlib/ I'm not sure how you'd extend that to be compatible with more things running under other subdirectories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants