rejetto / hfs

HFS is a web file server to run on your computer. Share folders or even a single file thanks to the virtual file system.
GNU General Public License v3.0
2.13k stars 209 forks source link

Account -> Redirect subtly breaks if you do not start with a slash #585

Closed soleofthesea closed 4 months ago

soleofthesea commented 4 months ago

Let's say I have a HFS server that can be accessed via https://example.com/files.

If I open the Admin panel -> Accounts, there is the option 'Redirect' to automtically bring the user to a certain folder.

If I input foo, logging in will take me to https://example.com/foo, with the files part deleted. Browsing files works, but attempting to open anything returns a 404.

If I input /foo, then everything works properly.

rejetto commented 4 months ago

you mean that you have a reverse-proxy that maps /files to your HFS root? https://github.com/rejetto/hfs/wiki/Reverse-proxy

soleofthesea commented 4 months ago

Yes, that is correct.

rejetto commented 4 months ago

ok, the solution to your problem is in the link that i posted above.

You should already see a link saying "Read our guide on proxies" inside the home page of the Admin-panel. Can you confirm?

soleofthesea commented 4 months ago

My NGINX config params are identical to the example provided and I have indeed setup the correct URL in section 'Internet'.

To note, the proxy itself works, and so is the option I am filing this bug report for - as long as you have put a leading / at the start. But the settings allow you to omit it.

image

rejetto commented 4 months ago

you say the setting "allow" you to omit the leading /, but that sounds right, as i expect some cases you want to have relative links, instead of absolute links. In the end you can enter anything, right?

image

can you enter the leading / correctly in the field?

anyway, i had a closer look to the "redirect" function, and if i'm not mistaken, you are supposed to just enter "/" there, and your prefix of the reverse proxy should be prepended automatically. Can you give me a feedback about this?

rejetto commented 4 months ago

ok, maybe now i'm seeing what's happening here. the logic i'm applying for redirection is to automatically prefix with the reverse-proxy-prefix ONLY if the address you enter starts with / This was supposed to allow relative links, but from what you are saying it seems this is not working correctly. I'm going to test it.

soleofthesea commented 4 months ago

the logic i'm applying for redirection is to automatically prefix with the reverse-proxy-prefix ONLY if the address you enter starts with /

Yes, that's the part I'm hung up on. Is it intentional?

rejetto commented 4 months ago

it was intentional, but i still have to understand if that's the right thing to do

rejetto commented 4 months ago

please let me know about this

anyway, i had a closer look to the "redirect" function, and if i'm not mistaken, you are supposed to just enter "/" there, and your prefix of the reverse proxy should be prepended automatically. Can you give me a feedback about this?

soleofthesea commented 4 months ago

anyway, i had a closer look to the "redirect" function, and if i'm not mistaken, you are supposed to just enter "/" there, and your prefix of the reverse proxy should be prepended automatically. Can you give me a feedback about this?

Yup, no issues.

(Also I apologize: I used 'files' both for the NGINX location and the HFS subfolder. So the URL is https://example.com/files/Files. That must be confusing.)

I must admit, I'm not understanding what is the relative link feature intended for? As in, if I only type in foo, then where is it supposed to take me?

rejetto commented 4 months ago

the relative is for when you login while NOT in the root.

if you have "files" already in nginx configuration, you probably want hfs to not have the "files" folder, but just all things in the home.

rejetto commented 4 months ago

while testing, i've found that the account-redirect feature is broken since 0.52.1 😅

rejetto commented 4 months ago

i just updated the wiki page to include x-forwarded-host in the configuration. some features (like roots, that you may not use) will not work with it.

and i've just found a bug about roots+proxy. All fixed in next release.

rejetto commented 4 months ago

ok, all fixed in 0.52.6 thanks