GUI Apache reverse proxy and trailing slash

I’ve set up Apache as per https://docs.syncthing.net/users/reverseproxy.html with the following directives in the virtual host file:

ProxyPass /syncthing/ hxtp://localhost:8384/ <Location /syncthing/> ProxyPassReverse hxtp://localhost:8384/ Require all granted

The problem is if I go to hxtps://www.example.com/syncthing instead of hxtps://www.example.com/syncthing/ i.e. I omit the trailing slash, I get a 404.

Is there a simple way to correct this please?

I’ve tried redirecting with mod_rewrite and with Redirect etc. Like

RedirectPermanent /syncthing hxtps://example.com/syncthing/ ProxyPass /syncthing/ hxtp://localhost:8384/ <Location /syncthing/> ProxyPassReverse hxtp://localhost:8384/ Require all granted

My various attempts have failed, with hxtps://example.com/syncthing either returning a 404 or unrendered code apparently from the back-end of the GUI; meanwhile hxtps://example.com/syncthing/ still works.

Thank you!

(The “hxtp / hxtps” in the above are due to the forum software objecting to new users posting threads with multiple links in)

Remove the slash from the proxypass directive?

Thank you for the suggestion,

This results in hxtps://example.com/syncthing returning unrendered code:

And hxtps://example.com/syncthing/ returning the default, non-Syncthing, website for the domain.

Thanks

Perhaps you need to proxy/forward both.

The trailing slash is medatory, as all links (JS, CSS, API, …) are relative. So using a URL like https://example.com/syncthing will result in URLs like https://example.com/assets/css/theme.css while using a URL like https://example.com/syncthing/ will result in URLs like https://example.com/syncthing/assets/css/theme.css

This is my working config:

ProxyPass /syncthing/ http://127.0.0.1:8384/ retry=0
ProxyPassReverse /syncthing/ http://127.0.0.1:8384/
Redirect /syncthing /syncthing/

Thank you both very much for the thoughts, information and suggestions.

Duplicating the code for both /syncthing and /syncthing/ didn’t work: the /syncthing still returned unrendered code.

For some reason, the redirect directive after the proxypass directives didn’t work either; /syncthing returned a 404.

I’ve settled on the following, which does the trick:

# /syncthing and /syncthing/ - syncthing remote gui
RewriteEngine On
RewriteRule "^/syncthing$" "https://example.com/syncthing/" [R]
ProxyPass /syncthing/ http://127.0.0.1:8384/ retry=0
ProxyPassReverse /syncthing/ http://127.0.0.1:8384/

That has the desired effect of making https://example.com/syncthing redirect to https://example.com/syncthing/, and of the latter rendering and working properly. Doubtless overkill but it works.

Thank you once again

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.