Wednesday, January 2, 2013

Nginx Configuration example

Here is nginx configuration for some purpose. This example is for roundcube, drupal, and postfix.


server {
        listen       80 ;
        listen       443 ssl;


        #server_name  localhost;
        server_name myserver.com;

        ssl_certificate      server.crt;
        ssl_certificate_key  server.key;

        ssl_session_timeout  5m;

        ssl_protocols  SSLv2 SSLv3 TLSv1;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers   on;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /usr/local/www/nginx;
            index  index.html index.htm index.php;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/local/www/nginx-dist;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/www/$fastcgi_script_name;
            include        fastcgi_params;
        }



# Alias Directory

        location /roundcube {
        alias //usr/local/www/roundcube; # Roundcube directory
        #deny all;
        allow 192.168.7.0/24;
        deny all;
        index index.php;
        }

        location ~ /roundcube/.*\.php$ {
        if ($fastcgi_script_name ~ /roundcube(/.*\.php)$) {
        set $valid_fastcgi_script_name $1;
        }

        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/local/www/roundcube$valid_fastcgi_script_name;
        include fastcgi_params;
}

location /postfixadmin {
        alias //usr/local/www/postfixadmin; # Postifx Directory
        #deny all;
        allow 192.168.7.0/24;
        deny all;
        index index.php index.html index.htm;
        }

        location ~ /postfixadmin/.*\.php$ {
        if ($fastcgi_script_name ~ /postfixadmin(/.*\.php)$) {
        set $valid_fastcgi_script_name $1;
        }

        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/local/www/postfixadmin$valid_fastcgi_script_name;
        include fastcgi_params;
}

location /portal {
        alias //usr/local/www/portal; # Drupal directory
        #deny all;
#        allow 192.168.7.0/24;
        allow all;
        index index.php index.html index.htm;
        }

        location ~ /portal/.*\.php$ {
        if ($fastcgi_script_name ~ /portal(/.*\.php)$) {
        set $valid_fastcgi_script_name $1;
        }

        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/local/www/portal$valid_fastcgi_script_name;
        include fastcgi_params;
}
# End of alias directory
...


No comments:

Post a Comment