1 (edited by LainX84 2018-06-29 04:51:26)

Topic: [SOLVED] directory index of "/var/www/html/" is forbidden

======== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 0.9.8 MARIADB edition
- Linux/BSD distribution name and version: CentOS Linux release 7.5.1804 (Core)
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Hi to all,

i've just setup my new server with iRedMail.
I was able to configure correctly the mail server with SSL too (certbot) and create webmail.domain.com webpage.
Now i need to configure 2 domain each on different /var/www/html/<domain> folder.
I've create the correct conf file under /etc/nginx/sites-avaiable (and link it under /etc/nginx/sites-enable) but when i try to browser it appear the error "403 Forbidden - nginx".
Checking the /var/log/nginx/error.log i've the following entry  :

2018/06/28 15:51:31 [error] 1942#0: *1 directory index of "/var/www/html/" is forbidden, client: 15.195.185.75, server: _, request: "GET / HTTP/1.1", host: "www.magri.email"
2018/06/28 15:51:33 [error] 1942#0: *1 directory index of "/var/www/html/" is forbidden, client: 15.195.185.75, server: _, request: "GET / HTTP/1.1", host: "www.magri.email"
2018/06/28 15:52:14 [error] 1986#0: *1 directory index of "/var/www/html/" is forbidden, client: 15.195.185.75, server: _, request: "GET / HTTP/1.1", host: "www.magri.email"
2018/06/28 15:52:59 [error] 2019#0: *1 directory index of "/var/www/html/" is forbidden, client: 15.195.185.75, server: _, request: "GET / HTTP/1.1", host: "www.magri.email"
2018/06/28 15:53:01 [error] 2019#0: *1 directory index of "/var/www/html/" is forbidden, client: 15.195.185.75, server: _, request: "GET / HTTP/1.1", host: "www.magri.email"
2018/06/28 15:57:57 [error] 2019#0: *4 directory index of "/var/www/html/" is forbidden, client: 15.195.185.75, server: _, request: "GET / HTTP/1.1", host: "www.magri.email"

My conf file is the following :

server {
        listen 80;
        listen [::]:80;
        server_name magri.email www.magri.email;
        root "/var/www/html/magri.email";
        return 301 https://www.$server_name$request_uri;
        }

server {
        listen 443 ssl;
        listen [::]:443 ssl;
        server_name magri.email;
        return 301 https://www.$server_name;
        root /var/www/html/magri.email;
        index index.php index.html index.htm;
        include /etc/nginx/templates/hsts.tmpl;
        ssl on;
        ssl_dhparam /etc/nginx/ssl/dhparam.pem;
        ssl_certificate /etc/letsencrypt/live/website/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/website/privkey.pem;
        ssl_protocols TLSv1.2;
        ssl_ciphers "DHE-RSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:EC                                                        DHE-RSA-AES256-GCM-SHA384 !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
        ssl_prefer_server_ciphers on;
        ssl_session_cache shared:SSL:10m;

        location ~ \.php$ {
                        include /etc/nginx/templates/fastcgi_php.tmpl;
                        }
        }

Where i wrong because i try for more than 1 hour without find any kind of solution.

Thanks for your support.

Regards,
LainX84

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: [SOLVED] directory index of "/var/www/html/" is forbidden

I've fix it by modify the domain conf file :

server {
        listen 80;
        listen [::]:80;
        server_name magri.email www.magri.email;
        return 301 https://www.magri.email$request_uri;
        }

server {
        listen 443 ssl;
        listen [::]:443 ssl;
        server_name magri.email;
        return 301 https://www.$server_name;
        }
server {
        listen 443 ssl;
        listen [::]:443 ssl;
        server_name www.magri.email;
        root /var/www/html/magri.email/;
        index index.php index.html index.htm;
        include /etc/nginx/templates/hsts.tmpl;
        ssl on;
        ssl_dhparam /etc/nginx/ssl/dhparam.pem;
        ssl_certificate /etc/letsencrypt/live/website/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/website/privkey.pem;
        ssl_protocols TLSv1.2;
        ssl_ciphers "DHE-RSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-GCM-SHA384 !RC4 !aNULL !eNULL !LOW !3DES$
        ssl_prefer_server_ciphers on;
        ssl_session_cache shared:SSL:10m;

        location ~ \.php$ {
                        include /etc/nginx/templates/fastcgi_php.tmpl;
                        }
        }

But i can't open PHP page (i've try to use wordpress).

Sigh..

3

Re: [SOLVED] directory index of "/var/www/html/" is forbidden

Solved!

I've delete that :

location ~ \.php$ {
                        include /etc/nginx/templates/fastcgi_php.tmpl;
                        }

And change with that :

include /etc/nginx/templates/php-catchall.tmpl;

Now everything works as I wanted!