1 (edited by carlkyo 2015-02-11 12:58:19)

Topic: nginx sub-directory

==== Required information ====
- iRedMail version: 0.9
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Linux/BSD distribution name and version: centos 6.6 php-5.4.37
- Related log if you're reporting an issue:
====
Hi Guys
I wanna add a sub-directory doc inside /var/www , and here is my configuration .it can not display any php file
can everyone help?
any help will be greatly appreciated

    location /doc/ {
    alias /var/www/doc/;
    #root /var/www/;
    index index.php index.html index.htm ;
    autoindex on;
    }
    location ~ /doc/.+\.php.*$ {
#    if ($fastcgi_script_name ~ /doc/(.+\.php.*)$) {
#    set $valid_fastcgi_script_name $1;     
#    }
    include fastcgi_params;
#        fastcgi_pass php_workers;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index index.php; 
#    fastcgi_param  SCRIPT_FILENAME  /var/www/doc/$valid_fastcgi_script_name;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

----

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

2

Re: nginx sub-directory

What Nginx setting did you modify? Any error message in its log file?

3 (edited by carlkyo 2015-02-11 15:20:10)

Re: nginx sub-directory

ZhangHuangbin wrote:

What Nginx setting did you modify? Any error message in its log file?

Hi Zhang
thanks for your quickly support
I try another simple way
I move the doc folder into /var/www/html  and chmod -R 0755
and then add autoindex on; to /etc/nginx/conf.d/default.conf
it can read any file of  html but php
can you help.
thanks
home.php source

<?php
echo  "<h1>Hello</h1>";
?>

[root@mail conf.d]# tail /var/log/nginx/error.log
[root@mail conf.d]#
[root@mail conf.d]# php -v
PHP 5.4.37 (cli) (built: Jan 21 2015 11:11:59)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
[root@mail conf.d]# ps -ef|grep php
root      3200     1  0 11:35 ?        00:00:00 php-fpm: master process (/etc/php-fpm.conf)
apache    3201  3200  0 11:35 ?        00:00:00 php-fpm: pool www
apache    3202  3200  0 11:35 ?        00:00:00 php-fpm: pool www
apache    3203  3200  0 11:35 ?        00:00:00 php-fpm: pool www
apache    3204  3200  0 11:35 ?        00:00:00 php-fpm: pool www
apache    3205  3200  0 11:35 ?        00:00:00 php-fpm: pool www
root      5081  2590  0 15:18 pts/0    00:00:00 grep php

Post's attachments

nginx.gif
nginx.gif 41.97 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

4

Re: nginx sub-directory

solved
thanks

# HTTP
server {
    listen 80;
    server_name _;

    root /var/www/html;
    index index.php index.html index.htm;

    location / {
        root /var/www/html;
        autoindex on;

    }

    # Normal PHP scripts
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass php_workers;
        fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
    }

    # Redirect webmail/SOGo/iredadmin to HTTPS
    location ~ ^/mail { rewrite ^ https://$host$request_uri?; }
    location ~* ^/sogo { rewrite ^ https://$host/SOGo; }
    location ~ ^/iredadmin { rewrite ^ https://$host$request_uri?; }
    location ~ ^/phpmyadmin { rewrite ^ https://$host$request_uri?; }

    # Deny all attempts to access hidden files such as .htaccess.
    location ~ /\. {
        deny all;
        access_log off;
        log_not_found off;
    }


    # Handling noisy favicon.ico messages
    location = /favicon.ico {
        access_log off;
        log_not_found off;
    }
}

5

Re: nginx sub-directory

Solved by adding below line?

    location ~ \.php$ {
        ...
        fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;      # <- this line?
    }

Looks like iRedMail bug. will fix it in next release.

6

Re: nginx sub-directory

ZhangHuangbin wrote:

Solved by adding below line?

    location ~ \.php$ {
        ...
        fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;      # <- this line?
    }

Looks like iRedMail bug. will fix it in next release.

yes
thanks

7

Re: nginx sub-directory

Fixed in iRedMail development version. Thanks for your feedback and fix. smile