Open jdeus opened 1 year ago
Thanks for opening your first issue here! Just a reminder, this forum is for Bug Reports only. Be sure to follow the issue template!
I can second that. I've read in previous issues that ZM_BASE_URL is deprecated, but the idea is sound.
I also tried injecting a
sub_filter '</head>' '<base href="/my/cams/admin"></head>';
In the browser's js console, I still see lots of red 404 entries.
I also tried setting HTTP headers that, according to spec, are supposed to suggest base URI. Apparently, both
proxy_set_header Content-Location /my/cams/admin;
proxy_set_header Content-Base /my/cams/admin;
We do need a mechanism to reliably hide ZM behind a reverse proxy. Preferably, this mechanism should use either relative URLs or standard absolute URL prefixing mechnisms (
Unfortunately, I'm not a PHP dev and can't contribute much.
Another probably related issue: some URLs are stepping one level up. Say, if my actual base URL is /my/cams/admin, some resources are being fetched from /my/cams (losing the /admin part of the URL).
A temporary somewhat working workaround:
location ~ ^/my/cams/admin/?(.*) {
proxy_pass http://localhost:81/$1$is_args$args;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
sub_filter 'src="/' 'src="';
sub_filter 'href="/' 'href="';
sub_filter '/index.php' 'index.php';
sub_filter_once off;
}
location ~ ^/my/cams/?(.*) {
proxy_pass http://localhost:81/$1$is_args$args;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
sub_filter 'src="/' 'src="';
sub_filter 'href="/' 'href="';
sub_filter '/index.php' 'index.php';
sub_filter_once off;
}
Still, snapshot thumbnails are attempted to fetch from an absolute /index.php. Android app is having trouble automatically detecting cgi-bin (had to specify the path manually; still doesn't load monitors). Prolly something else is broken as well.
At least I can view the stream in the web browser now.
Still, this has to be fixed.
I run ZM behind reverse proxies all the time.... with and with the /zm.... havn't done a more complex url change.
The issue is further complicated by multi-server. Wherever we are using an absolute url, we are likely dealing with a multi-server case.
@connortechnology
@connortechnology want to answer this so we can close it or add to list for 1.38?
I think we need to add it to the list.
I'm not sure about img url's... but the redirects for login and privacy use ZM_BASE_URL and I don't see why. Unfortunately I don't think we can get this in for 1.36.35 but I think we can certainly do away with BASE_URL entirely.
Actually it's a pretty small change... maybe it could go in 1.36.35.
Describe Your Environment
Describe the bug All web elements should be requested using a relative path, as described by ZM_BASE_URL. However, when setup using a reverse proxy on /services/zoneminder, it's appartent that a lot of resources are requested using an absolute path and breaks a lot of features :
/cgi-bin/nph-zms
) in the htmlsrc="/cgi-bin/nph-zms?...
rp-nginx/nginx.conf :
docker-compose.yml