user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

    server {
        listen <YOURLOCALIP>:8000;

        root /srv/nginx;
        index index.php index.html index.htm;

        server_name <YOURSERVERNAME>;

        location / {
                try_files $uri $uri/ /index.html;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

                # With php5-cgi alone:
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

        location ~ /\.ht {
                deny all;
        }

    }
}

mail {
    auth_http  <YOURLOCALIP>:8000/dbmailauth.php;


    proxy      on;
    ssl        on;

    ssl_prefer_server_ciphers  on;
    ssl_protocols              TLSv1 SSLv3;
    ssl_ciphers                HIGH:!ADH:!MD5:@STRENGTH;
    ssl_session_cache          shared:TLSSL:16m;
    ssl_session_timeout        10m;
    ssl_certificate            /etc/dbmail/ssl/<YOURSERVERNAME>.pem;
    ssl_certificate_key        /etc/dbmail/ssl/<YOURSERVERNAME>.key;


    server {
        listen     995;
        protocol   pop3;
        pop3_auth plain apop cram-md5;
        server_name <YOURSERVERNAME>;
    }

    server {
        listen     993;
        protocol   imap;
        imap_auth login plain cram-md5;
        server_name <YOURSERVERNAME>;
    }
}

mail {
    auth_http  <YOURLOCALIP>:8000/dbmailauth.php;

    proxy      on;
    starttls   on;

    ssl_prefer_server_ciphers  on;
    ssl_protocols              TLSv1 SSLv3;
    ssl_ciphers                HIGH:!ADH:!MD5:@STRENGTH;
    ssl_session_cache          shared:TLSSL:16m;
    ssl_session_timeout        10m;
    ssl_certificate            /etc/dbmail/ssl/<YOURSERVERNAME>.pem;
    ssl_certificate_key        /etc/dbmail/ssl/<YOURSERVERNAME>.key;

    ssl_session_timeout        10m;
    ssl_certificate            /etc/dbmail/ssl/<YOURSERVERNAME>.pem;
    ssl_certificate_key        /etc/dbmail/ssl/<YOURSERVERNAME>.key;


    server {
        listen     995;
        protocol   pop3;
        pop3_auth plain apop cram-md5;
        server_name <YOURSERVERNAME>;
    }

    server {
        listen     993;
        protocol   imap;
        imap_auth login plain cram-md5;
        server_name <YOURSERVERNAME>;
    }
}

mail {
    auth_http  <YOURLOCALIP>:8000/dbmailauth.php;

    proxy      on;
    starttls   on;

    ssl_prefer_server_ciphers  on;
    ssl_protocols              TLSv1 SSLv3;
    ssl_ciphers                HIGH:!ADH:!MD5:@STRENGTH;
    ssl_session_cache          shared:TLSSL:16m;
    ssl_session_timeout        10m;
    ssl_certificate            /etc/dbmail/ssl/<YOURSERVERNAME>.pem;
    ssl_certificate_key        /etc/dbmail/ssl/<YOURSERVERNAME>.key;

    server {
        listen     110;
        protocol   pop3;
        pop3_auth plain apop cram-md5;
        server_name <YOURSERVERNAME>;
    }
    server {
        listen     143;
        protocol   imap;
        imap_auth login plain cram-md5;
        server_name <YOURSERVERNAME>;
    }
}
