API links broken in reverse-proxy nginx variant
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:
- Use this config
- Open https://zm.example.com/zm/api/host/getversion.json in browser and witness 500 Internal Server Error.
- 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.
Thanks for opening your first issue here! Just a reminder, this forum is for Bug Reports only. Be sure to follow the issue template!
@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.
See this. https://stackoverflow.com/questions/29212655/nginx-php-scripts-not-being-called-from-reverse-proxy
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.
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.