Hi! I’m just starting to work with photostructure. It’s running successfully on localhost. Now I’m trying to reverse proxy from a path within my virtualserver host, like so:
I reverse proxy photostructure myself using traefik. I use a different domain for each app I reverse proxy to avoid the sort of problems you’re dealing with. Having said that, I dabbled a bit with what you’re trying to do with traefik, and I know it has the ability to rewrite URLs like this.
I don’t have first hand experience doing reverse proxy or URL rewriting with Apache, but a quick google shows a lot of info on this. search for “apache reverse proxy url rewrite” This might help Using mod_rewrite for Proxying - Apache HTTP Server Version 2.4
Thanks! Using a different domain (or a different port) seems to be the obvious workaround, at the cost of setting up a new virtual host on the proxy server (and perhaps some DNS glue and firewall hole-punching).
Nextcloud, for example, uses strategy 2, allowing admins to specify the web root under which the app lives (ref: nextcloud setting overwritewebroot described here.). Thus, the reverse proxy can simply map www.example.com/photos to https://localhost:8187/photos, and the app will always generate pages containing references with respect to the given webroot (i.e. <img src="/photos/images/foo.jpg"/>)
The mod_proxy_html option (couple answers down from the accepted one) is what I thought would be the Apache way to handle this. But I agree that if @mrm is willing to create yet another config option for this it would cleaner. Good luck! I’d vote for your feature request but I ran out of votes long ago…
The ideal solution would require no configuration, and have things “just work,” but if you need a different webroot, I think that’s going to require config.
An approach could be to add a <base> element whose content was sniffed from the requested URL (but could be overridden in settings to support different sub-path webroots, or more exotic hostname/port reverse proxy setups), and twiddle all generated URLs to not start with a forward slash.
I’d been using absolute path name URLs throughout mostly out of fear of old browser support of <base> and relative paths–but given that <base> was introduced ages ago, it has wide support.
(It’s OK to vote on your own feature requests, btw!)
My 2c: I used to try and use subdomains for each app, so I had www.example.com/appname type locations. I stopped this and now use subdomains for a few reasons:
It required every app to honour a subdirectory config (some like Nextcloud have this out of the box, lots don’t)
Wildcard certs got cheaper, as did auto-certificates for new subdomains
Password managers are easier to configure with subdomains
My vote would be to spend development effort elsewhere.