You don't have permission to access /cgi-bin/ on this server.

Forum for questions and support relating to the 1.32.x releases only.
Post Reply
Darkyere
Posts: 8
Joined: Fri Aug 09, 2019 7:38 am

You don't have permission to access /cgi-bin/ on this server.

Post by Darkyere »

Hi all and ty for reading.

I am a new user of Zoneminder.

I use Raspbian Buster as OS and Zoneminder 1.32.3

I have the problem that i cant watch the stream for my camera.
It seems like being some sort of permission issue but i cant find any info about my case on the web.

When clicking the Camera name it opens a window but shows no picture/stream.
When right clicking where the image is supposed to be and choosing to open stream link in another window i get

Code: Select all

Forbidden
You don't have permission to access /cgi-bin/ on this server.
Apache/2.4.38 (Raspbian) Server at 192.168.1.64 Port 80
Im not sure how to fix this and i cant find anything related to my case.

Ty for reading
Darkyere
Baylink
Posts: 338
Joined: Sun Jun 19, 2005 3:19 am

Re: You don't have permission to access /cgi-bin/ on this server.

Post by Baylink »

Generally, this has to do with the Apache config on the linux -- in your case, Raspbian -- server.

Exactly what's not happy depends on how Apache got installed; I think Raspbian has a package for it.

I'd try

# find / -name cgi-bin -print

to locate that directory, and then

# ls -ld $FULLPATHNAME

to see what the permissions actually are.

That's a start, anyways...
Darkyere
Posts: 8
Joined: Fri Aug 09, 2019 7:38 am

Re: You don't have permission to access /cgi-bin/ on this server.

Post by Darkyere »

Ty for the answer i appreciate it.

I have been busy helping my neighbor so sorry for responding so late.

I used

Code: Select all

find / -name cgi-bin -print

/usr/lib/zoneminder/cgi-bin
/usr/lib/cgi-bin
If im not mistaken taken from the configuration files the one in question is

Code: Select all

/usr/lib/zoneminder/cgi-bin
Since it needs the zms file that is in that location

The permissions on that directory goes is

Code: Select all

drwxr-xr-x 2 root root 4096 Jul 30 14:05 /usr/lib/zoneminder/cgi-bin
During the guide i followed i had to set permissions on certain directory's/files as following

Code: Select all

chown root:www-data /etc/zm/zm.conf
chmod 740 /etc/zm/zm.conf
I tried setting that on both

Code: Select all

/usr/lib/zoneminder/cgi-bin
/usr/lib/cgi-bin
But i still get permission issues.

Again ty and sry for responding so late since im helping out my neighboor and still dont know when i will be able to look at the forum again.
rockedge
Posts: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: You don't have permission to access /cgi-bin/ on this server.

Post by rockedge »

what does your apache /etc/apache2/configs-enabled/zoneminder.conf look like? (or /etc/apache2/configs-avialable/zoneminder.conf)

do you have the zoneminder.conf enabled?
Darkyere
Posts: 8
Joined: Fri Aug 09, 2019 7:38 am

Re: You don't have permission to access /cgi-bin/ on this server.

Post by Darkyere »

I seem to have mine located in

Code: Select all

ls -lah /etc/apache2/conf-enabled

lrwxrwxrwx 1 root root   30 Jul 30 13:56 charset.conf -> ../conf-available/charset.conf
lrwxrwxrwx 1 root root   44 Jul 30 13:56 localized-error-pages.conf -> ../conf-available/localized-error-pages.conf
lrwxrwxrwx 1 root root   46 Jul 30 13:56 other-vhosts-access-log.conf -> ../conf-available/other-vhosts-access-log.conf
lrwxrwxrwx 1 root root   31 Jul 30 13:56 security.conf -> ../conf-available/security.conf
lrwxrwxrwx 1 root root   36 Jul 30 13:56 serve-cgi-bin.conf -> ../conf-available/serve-cgi-bin.conf
lrwxrwxrwx 1 root root   33 Jul 30 14:13 zoneminder.conf -> ../conf-available/zoneminder.conf
-rw-r--r-- 1 root root  858 Jul 30 14:24 zoneminder.sav
And the zoneminder.conf looks like this

Code: Select all

########################
#
# Remember to enable cgi mod and serve-cgi-bin.conf configuration
#
# a2enmod cgi
# a2enconf serve-cgi-bin.conf
#
########################
# Order matters. This alias must come first.
Alias /zm/cache /var/cache/zoneminder
<Directory /var/cache/zoneminder>
    Options -Indexes +FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
Alias /zm /usr/share/zoneminder/www
<Directory /usr/share/zoneminder/www>
#  php_flag register_globals off
  Options -Indexes +FollowSymLinks
  <IfModule mod_authz_core.c>
           Require all granted
  </IfModule>
</Directory>
ScriptAlias /cgi-bin "/usr/lib/zoneminder/cgi-bin"
<Directory "/usr/lib/zoneminder/cgi-bin">
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    AllowOverride All
    Require all granted
</Directory>
<Directory "/usr/share/zoneminder/www/api">
   RewriteEngine on
   RewriteRule ^$ app/webroot/ [L]
   RewriteRule (.*) app/webroot/$1 [L]
   RewriteBase /zm/api
</Directory>
<Directory "/usr/share/zoneminder/www/api/app">
   RewriteEngine on
   RewriteRule ^$ webroot/ [L]
   RewriteRule (.*) webroot/$1 [L]
   RewriteBase /zm/api
</Directory>
<Directory "/usr/share/zoneminder/www/api/app/webroot">
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    RewriteBase /zm/api
</Directory>
Is this as it should be ?

I followed a tutorial that told to change that specific file.

I luckely enough saved the old file as zoneminder.sav and that one looks like

Code: Select all

# Remember to enable cgi mod (i.e. "a2enmod cgi").
ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
<Directory "/usr/lib/zoneminder/cgi-bin">
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    AllowOverride All
    Require all granted
</Directory>

    # Order matters. This alias must come first.
    Alias /zm/cache "/var/cache/zoneminder"
    <Directory "/var/cache/zoneminder">
        Options -Indexes +FollowSymLinks
        AllowOverride None
        <IfModule mod_authz_core.c>
           # Apache 2.4
           Require all granted
        </IfModule>
    </Directory>

Alias /zm /usr/share/zoneminder/www
<Directory /usr/share/zoneminder/www>
  Options -Indexes +FollowSymLinks
  <IfModule mod_dir.c>
    DirectoryIndex index.php
  </IfModule>
</Directory>

<Directory /usr/share/zoneminder/www/api>
    AllowOverride All
</Directory>
The cgi-part seems to be the same except in

Code: Select all

zoneminder.conf

ScriptAlias /cgi-bin "/usr/lib/zoneminder/cgi-bin"
and

Code: Select all

zoneminder.sav

ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
I partly followed a Raspbian Zoneminder tutorial and the wiki

https://wiki.zoneminder.com/Debian_10_B ... e_Easy_Way

If i add to zoneminder.conf

ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"

instead i get

The requested URL /cgi-bin was not found on this server.
Baylink
Posts: 338
Joined: Sun Jun 19, 2005 3:19 am

Re: You don't have permission to access /cgi-bin/ on this server.

Post by Baylink »

I think the next thing you need to do is make sure your zoneminder user has at least search (x) permission on all the components of

/usr/lib/zoneminder/cgi-bin

If your ls(1) has the switch, you can use^W^W^W^W^W^W^W

Well, I *thought* ls had a switch to show all the directories in a pathname...

Anyways: try

$ ls -ld /usr/lib/zoneminder
$ ls -ld /usr/lib
$ ls -ld /usr
$ ls -ld /

and make sure that everything in the path has at least x permission for whatever user your webserver runs as (www, apache, whathaveyou); I don't think it needs r permission until the cgi-bin directory. You've already shown that's ok.
Darkyere
Posts: 8
Joined: Fri Aug 09, 2019 7:38 am

Re: You don't have permission to access /cgi-bin/ on this server.

Post by Darkyere »

I know it seems odd but it seems like it has execute everywhere

Code: Select all

root@RPI2:/home/DYbvRBDO# ls -ld /usr/lib/zoneminder/cgi-bin
drwxr-xr-x 2 root www-data 4096 Jul 30 14:05 /usr/lib/zoneminder/cgi-bin
root@RPI2:/home/DYbvRBDO# ls -ld /usr/lib/zoneminder
drwxr-xr-x 3 root root 4096 Jul 30 14:04 /usr/lib/zoneminder
root@RPI2:/home/DYbvRBDO# ls -ld /usr/lib/
drwxr-xr-x 101 root root 4096 Aug  9 11:52 /usr/lib/
root@RPI2:/home/DYbvRBDO# ls -ld /usr/
drwxr-xr-x 11 root root 4096 Jul 25 15:54 /usr/
root@RPI2:/home/DYbvRBDO# ls -ld /
drwxr-xr-x 21 root root 4096 Jul 29 13:59 /
Baylink
Posts: 338
Joined: Sun Jun 19, 2005 3:19 am

Re: You don't have permission to access /cgi-bin/ on this server.

Post by Baylink »

Yup, it appears you do... unless that's not the /cgi-bin/ that it's complaining about.

It's not possible you have more than one apache installed on that machine, is it?
Darkyere
Posts: 8
Joined: Fri Aug 09, 2019 7:38 am

Re: You don't have permission to access /cgi-bin/ on this server.

Post by Darkyere »

Hmm that is a possibility i suppose.

I have OpenHAB2, RPI-Monitor, and Shinobi (Dont mind the wrong name i think its gettting cencured its S-h-i-n-o-b-i) that are using some sort of web interface.

I think that OpenHAB2 runs on some sort of apache version or something similar but im not sure.

The weird part even with another version of Apache 2.

When it was Raspbian Stretch and Zoneminder 1.30.4 it did coexcist fine.

But now with Raspbian Buster and Zoneminder 1.32.3 im suddenly having these weird issue.
Darkyere
Posts: 8
Joined: Fri Aug 09, 2019 7:38 am

Re: You don't have permission to access /cgi-bin/ on this server.

Post by Darkyere »

Okay just for the heck of it i tried putting a script i found on the net in /usr/lib/cgi-bin

Code: Select all

nano /usr/lib/cgi-bin/test.pl
#!/usr/bin/perl -w
print "Content-type: text/html\r\n\r\n";
print "Hello there!<br />\nJust testing .<br />\n";
for ($i=0; $i<10; $i++)
{
print $i."<br />";
}
When giong to http://IP/cgi-bin/test.pl

i get

Code: Select all

Hello there!
Just testing .
0
1
2
3
4
5
6
7
8
9
Does this mean zoneminder or Apache2 is pointed in the wrong direction somewhere ?
Or is it just apache2 pointing there ?
Weird i can get acces to that one but not as http://IP/zm
Darkyere
Posts: 8
Joined: Fri Aug 09, 2019 7:38 am

Re: You don't have permission to access /cgi-bin/ on this server.

Post by Darkyere »

Okay this is starting to make sence.
Zoneminder is right now "looking" inside /usr/lib/cgi-bin

I allso found that the path for cgi-bin / zms for zoneminder is controlled by a fil here

Code: Select all

 ls -lah /etc/zm/conf.d
total 24K
drwxr-xr-x 2 root root 4.0K Aug  9 09:19 .
drwxr-xr-x 3 root root 4.0K Aug 12 21:40 ..
-rw-r--r-- 1 root root 2.0K Aug  9 09:17 01-system-paths.conf
-rw-r--r-- 1 root root  395 Dec  8  2018 02-multiserver.conf
-rw-r--r-- 1 root root  126 Aug  7 20:13 backupandsync.conf
-rw-r--r-- 1 root root  740 Dec  8  2018 README

nano /etc/zm/conf.d/01-system-paths.conf

ZM_PATH_ZMS=/cgi-bin
if i change that to etc

Code: Select all

ZM_PATH_ZMS=/usr/lib/zoneminder/cgi-bin
i finally get another respond in the window now saying

The requested URL /usr/lib/zoneminder/cgi-bin was not found on this server.
Darkyere
Posts: 8
Joined: Fri Aug 09, 2019 7:38 am

Re: You don't have permission to access /cgi-bin/ on this server.

Post by Darkyere »

I found the solution. And i hope its its working not.

I changed

Code: Select all

nano /etc/apache2/conf-enabled/zoneminder.conf
from the long bloated version i found recommended on the net to the origional file

Code: Select all

# Remember to enable cgi mod (i.e. "a2enmod cgi").
ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
<Directory "/usr/lib/zoneminder/cgi-bin">
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    AllowOverride All
    Require all granted
</Directory>

    # Order matters. This alias must come first.
    Alias /zm/cache "/var/cache/zoneminder"
    <Directory "/var/cache/zoneminder">
        Options -Indexes +FollowSymLinks
        AllowOverride None
        <IfModule mod_authz_core.c>
           # Apache 2.4
           Require all granted
        </IfModule>
    </Directory>

Alias /zm /usr/share/zoneminder/www
<Directory /usr/share/zoneminder/www>
  Options -Indexes +FollowSymLinks
  <IfModule mod_dir.c>
    DirectoryIndex index.php
  </IfModule>
</Directory>

<Directory /usr/share/zoneminder/www/api>
    AllowOverride All
</Directory>
# And created

Code: Select all

nano /etc/zm/conf.d/custom_paths.conf
ZM_PATH_ZMS=/zm/cgi-bin/nph-zms
ZM_PATH_CGI=/usr/lib/zoneminder/cgi-bin
Restarted apache2 since i changed the apache2 configuration file /etc/apache2/conf-enabled/zoneminder.conf

And restarted ZoneMinder since i created this new configuration file /etc/zm/conf.d/custom_paths.conf

And now i have a streaming window running with no problem
Baylink
Posts: 338
Joined: Sun Jun 19, 2005 3:19 am

Re: You don't have permission to access /cgi-bin/ on this server.

Post by Baylink »

#nice

:-)
Post Reply