zoneminder icon indicating copy to clipboard operation
zoneminder copied to clipboard

API links broken in reverse-proxy nginx variant

Open ivdok opened this issue 5 years ago • 5 comments

Describe Your Environment

  • ZoneMinder v1.34.20 (TurnKey Linux appliance)

Describe the bug Redirection loops occurs when using Nginx in front of Apache + ZoneMinder, when setting up according to zmNinja author's instructions - they are meant for situation when Nginx is the main web server, and not a reverse proxy like in my case.

To Reproduce Steps to reproduce the behavior:

  1. Use this config
  2. Open https://zm.example.com/zm/api/host/getversion.json in browser and witness 500 Internal Server Error.
  3. See following in Nginx logs:
2020/09/10 03:40:39 [error] 47382#47382: *1 rewrite or internal redirection cycle while processing "/zm/api/index.php", client: 95.79.x.x, server: zm.example.com, request: "GET /zm/api/host/getVersion.json HTTP/2.0", host: "zm.example.com"

Expected behavior Working API for zmNinja and SurveillancePro

Debug Logs Unapplicable here.

ivdok avatar Sep 10 '20 00:09 ivdok

Thanks for opening your first issue here! Just a reminder, this forum is for Bug Reports only. Be sure to follow the issue template!

welcome[bot] avatar Sep 10 '20 00:09 welcome[bot]

@ivdok

The problem here is that the index.php is trying to be procecssed by nginx. You can use this config to fix it. The ^~ makes the /zm location take precedence over the php declaration

        # ZONEMINDER
        location _^~ /zm_ {
            proxy_pass http://zmserver.localdomain:8180/zm;
            proxy_connect_timeout    300;
            proxy_send_timeout       300;
            proxy_read_timeout       300;
            send_timeout                     300;
	    proxy_http_version 1.1;             
            proxy_buffering off; # Needed for FIFO raw mode. 

        }

This is working well for me.

vajonam avatar Nov 30 '20 19:11 vajonam

See this. https://stackoverflow.com/questions/29212655/nginx-php-scripts-not-being-called-from-reverse-proxy

vajonam avatar Nov 30 '20 19:11 vajonam

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 11 '21 01:06 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 06:04 stale[bot]