Working reverse proxy setup from Nginx to zm Apache?

Forum for questions and support relating to the 1.25.x releases only.
Locked
User avatar
c128
Posts: 88
Joined: Sat Sep 14, 2013 3:36 pm

Working reverse proxy setup from Nginx to zm Apache?

Post by c128 »

Note: I did have a whole set of extracts of my current Nginx config I was going to post here, but as a new user I can't get anything by the "Your post looks too spamy for a new user, please remove off-site URLs.", despite there being no off-site URLs within it - dunno what it's triggering on, but I had to remove all of it. Sorry for the lack of detail :( .

Basically I have an Nginx front-end webserver that proxy redirects various sub-directories of my domain to internal machines running their own webservers - these all work fine. However, I just can't get a working setup with Zoneminder.

Any advice on getting a working setup when reverse proxying from a front-end Nginx webserver to a internal Zoneminder, running with Apache, on an internal machine?

Any obvious gotchas?
User avatar
c128
Posts: 88
Joined: Sat Sep 14, 2013 3:36 pm

Re: Working reverse proxy setup from Nginx to zm Apache?

Post by c128 »

Right, I seem to be able to post some detail now...
Obviously that's not _internal_ip_ in reality in the below, it's the local IP of my internal Zoneminder machine (that I can't put in due to the "Spamy" filter) but here's the config I'm currently using for Nginx :) :

Code: Select all

        location ^~ /zm {
                proxy_pass _internal_ip_/zm;
                proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
I'm using the above, in combination with a workaround I found on another forum that advises a mod to Zoneminder's index.php for ZM_BASE_URL :

Code: Select all

if (!isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
        define( "ZM_BASE_URL", $protocol.'://'.$_SERVER['HTTP_HOST'] );
}
else
{
        define( "ZM_BASE_URL", $protocol.'://'.$_SERVER['HTTP_X_FORWARDED_HOST'] );
}
Last edited by c128 on Sat Sep 14, 2013 9:57 pm, edited 1 time in total.
User avatar
c128
Posts: 88
Joined: Sat Sep 14, 2013 3:36 pm

Re: Working reverse proxy setup from Nginx to zm Apache?

Post by c128 »

Now...although I can login to Zoneminder via _external_ip_/zm , the login sticks on the "Logging in" screen. If I manually refresh to _external_ip_/zm I get to the main screen listing my cams and I am logged in. However, if I click on a cam to monitor it live, the viewing screen opens within the same window (rather than popping up a new one) and live stream viewing doesn't work - Cambozola displays an exception with "Connection refused: connect".

"Options" seems to work but, again, opens with the same screen rather than popping up a new one.

Everything works fine when accessing Zoneminder directly, within my LAN, using _internal_ip/zm, so it's the reverse proxy from my front-end Nginx to my backend Zoneminder Apache that seems to be the problem.

I suspect I'm missing something obvious with proxy forwarding PHP related stuff or something, but none of the many tweaks I've tried gives me anything better than the above.

Anything obvious I can try here to get this reverse proxy working?
Locked