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

How to correctly run wfm behind a nginx proxy? #58

Open
egrath opened this issue Aug 8, 2024 · 3 comments
Open

How to correctly run wfm behind a nginx proxy? #58

egrath opened this issue Aug 8, 2024 · 3 comments

Comments

@egrath
Copy link

egrath commented Aug 8, 2024

Hi,

i'm trying to run wfm behind a nginx proxy server. My setup is as follows:

www.example.com/wfm should be redirected to a locally running wfm instance. wfm is using the following configuration:

/usr/local/sbin/wfm-amd64-linux \
    -addr=127.0.0.1:1728 \
    -chroot=/var/www/html/filesink \
    -setuid=www-data \
    -passwd=/etc/wfm-passwd.json \
    -prefix=/:/wfm/

nginx is set up to proxy requests to www.example.com/wfm to port 127.0.0.1:1728:

location /wfm/ {
	client_max_body_size 1024M;
	proxy_buffering off;
	proxy_pass http://127.0.0.1:1728;
}

It works in general, but only for files in the root directory. If for example i create a directory in wfm, change into it and upload a file there, I'm not able to open this file from wfm as it results in a 404 from nginx. So I assume my nginx configuration for reverse proxying the requests is somehow broken.

Would be great to have some hints in the documentation on how to run wfm behind a nginx or Apache reverse proxy.

@tenox7
Copy link
Owner

tenox7 commented Aug 13, 2024

Thank you for reporting this. I think that the problem may be that you're passing a fixed location /wfm/ - while you need to pass all subdirectories.

You may want to implement something as described here:

https://serverfault.com/questions/792326/nginx-proxy-pass-using-subfolder

If this doesn't work, WFM can also operate in a non-path mode where directory and filename are specified as query strings. I probably need to make it a flag.

@egrath
Copy link
Author

egrath commented Aug 13, 2024

Unfortunately, that didn't worked out. Modified my configuration to:

        location ~ ^/wfm(?<sdir>.*)$ {
                client_max_body_size 1024M;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header Host $host;
                proxy_buffering off;
                proxy_pass http://127.0.0.1:1728$sdir;
        }

But now only get a 404 produced by wfm for everything

/edit: I now played around a little bit and got it working wth:

        location ^~ /wfm/ {
                client_max_body_size 1024M;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header Host $host;
                proxy_buffering off;
                proxy_pass http://127.0.0.1:1728;
        }

Unfortunately, I don't know why because it's not really different than my original configuration with the exception that i told nginx to do a regular expression parsing on the location - but there are no regular expressions in it, so it shouldn't make any difference at all.

@tenox7
Copy link
Owner

tenox7 commented Sep 4, 2024

bump, let me try to reproduce this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants