Source

iredmail / iRedMail / samples / nginx / default.conf

upstream php_workers {
    server PH_FASTCGI_PASS;
}

# HTTP
server {
    listen PH_HTTPD_PORT;
    server_name  _;

    root PH_HTTPD_SERVERROOT;
    index index.php index.html index.htm;

    location / {
        root   PH_HTTPD_DOCUMENTROOT;
    }

    # Normal PHP scripts
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass php_workers;
    }

    # Redirect /mail/ to https
    location ~ /mail/ {
        rewrite ^ https://$host$request_uri?;
    }

    # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
    location ~ /\. { deny all; access_log off; log_not_found off; }

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

# HTTPS
server {
    listen PH_HTTPS_PORT;
    server_name _;

    ssl on;
    ssl_certificate PH_SSL_CERT_FILE;
    ssl_certificate_key PH_SSL_KEY_FILE;

    # Roundcube webmail
    location ~ /mail(.*)\.php$ {
        include fastcgi_params;
        fastcgi_pass php_workers;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME PH_RCM_HTTPD_ROOT_SYMBOL_LINK$1.php;
    }

    location ~ /mail(.*) {
        alias PH_RCM_HTTPD_ROOT_SYMBOL_LINK$1;
        index index.php;
    }

    location ~ ^/mail/(bin|SQL|README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ { deny all; }

    # phpLDAPadmin
    location ~ /phpldapadmin(.*)\.php$ {
        include fastcgi_params;
        fastcgi_pass php_workers;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME PH_PLA_HTTPD_ROOT_SYMBOL_LINK$1.php;
    }

    location ~ /phpldapadmin(.*) {
        alias PH_PLA_HTTPD_ROOT_SYMBOL_LINK$1;
        index index.php;
    }

    # phpMyAdmin
    location ~ /phpmyadmin(.*)\.php$ {
        include fastcgi_params;
        fastcgi_pass php_workers;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME PH_PHPMYADMIN_HTTPD_ROOT_SYMBOL_LINK$1.php;
    }

    location ~ /phpmyadmin(.*) {
        alias PH_PHPMYADMIN_HTTPD_ROOT_SYMBOL_LINK$1;
        index index.php;
    }

    # Normal PHP scripts
    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass php_workers;
    }

    #location ~ /iredadmin(.*) {
    #    include uwsgi_params;
    #    uwsgi_pass unix:/var/run/uwsgi/app/iredmail/socket;
    #    uwsgi_param UWSGI_PYHOME /usr/share/apache2/iredadmin/python-home;
    #    uwsgi_param UWSGI_CHDIR /usr/share/apache2/iredadmin;
    #    uwsgi_param UWSGI_SCRIPT iredadmin;
    #}

    #location ~ /iredadmin(.*) {
    #    alias /var/www/iredadmin$1;
    #}

    #location /iredadmin/static {
    #    alias /var/www/iredadmin/static;
    #}
}