FLC doesn't work with reverse-proxies using a path
NullOrNaN opened this issue · comments
I was taking a look at your application that was posted on Reddit and noticed that you advertised that it can connect to HTTP(S) servers. I have a few Foundry installs I use myself and use sub directories off of my site to proxy them to. This feature is supported by Foundry themselves as you have to edit a config value for it to work, and while a more advanced use case, I can see it breaking some other setups too.
To reproduce setup a FoundryVTT install behind a reverse proxy such as Nginx with a path.
Example of an Nginx config that would allow this:
location /vtt/ctg {
proxy_read_timeout 90;
client_max_body_size 500M;
proxy_set_header Connection "Upgrade";
proxy_headers_hash_max_size 1024;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http:/localhost:31005;
}
The config lines for Foundry that need to be adjusted for this are as follows (this is assuming an HTTPS reverse proxy):
{
...
"hostname": "example.com",
"localHostname": "example.com",
"proxyPort": 443,
"proxySSL": true,
"routePrefix": "path/to/foundry",
...
}
If I can assist by providing any more information or testing let me know!
@NullOrNaN have you tried enabling Server check bypass (a Shield icon at the top)? I added it for such niche cases (reverse-proxy, http password-protected servers, etc).
It doesn't work with that sadly, it works with my setup for any subdomains but anything off of my main site won't work as it appears to be stripping the path.
In short:
https://vtt.example.com - WORKS!
https://example.com/vtt/ - Doesn't work
I'll be glad to setup and provide a test environment for Foundry for you to test against if you'd like as I have a spare license.
Just did some quick digging and it looks to be calling only the host here when trying to connect so we'd have to expand what we define/save for it.
I'm aware that this is an edge-use case and I might need to fork the repo and make the changes myself, but figured I'd report it first.
https://vtt.example.com/ - WORKS!
https://example.com/vtt/ - Doesn't work
I see. Yes, I haven't thought about sub-paths for such cases.
Here I strip URL of any extras during validation:
Lines 43 to 45 in b0d6ef9
Should be an easy fix, I will release it with the next update. Thanks!
May I make a suggestion? Allow a path to be defined on it's own apart from the host? This will allow your code to handle a safety check and also allow paths. You might wish to parse a path using regexp then.
Thank you for your quick replies and looking forward to having my players test this out!
@NullOrNaN I've released 2.7.0 (app has an auto-updater). See if your issue is fixed.
I'm able to connect now and DM. I'm closing this now and will submit some feature ideas as a thanks once I get to play with it a bit more!