worker_processes 1;
error_log __ROOT__/error.log;
# error_log error.log;
pid __ROOT__/server.pid;
daemon off;
 

events {
    worker_connections 4096;
}

 
http {
    include __ROOT__/mime.types;
    
    default_type application/octet-stream;
    log_format main '$remote_addr - $remote_user [$time_local] $status '
        '"$request" $body_bytes_sent "$http_referer" '
        '"$http_user_agent" "$http_x_forwarded_for"';
    sendfile on;
    tcp_nopush on;
    autoindex on;

    server {
        listen __HTTP_PORT__;
        server_name www.__HTTP_HOST__;
        access_log __ROOT__/access.log main;
        rewrite ^(.*) http://__HTTP_HOST__:__HTTP_PORT__$1 permanent;
    }

    server {
        listen __HTTP_PORT__;
        server_name __HTTP_HOST__;
        access_log __ROOT__/access.log main;
        # access_log access.log main;

        root __ROOT__/html;

#         location / {
#             index index.html index.txt index.php;
#             rewrite (.*) /app/webroot$1 last;
#             rewrite ^$ /app/webroot last;
#         }
# 
#         location /app/webroot {
#             index index.html index.txt index.php;
#         }
# 
#         location ~ \.php$ {
#             include __ROOT__/fastcgi_params;
#             fastcgi_pass 127.0.0.1:__PHP_FCGI_PORT__;
#         }

        location / {
            root __ROOT__/html/app/webroot/;
            index index.php index.html index.htm;
            if (-f $request_filename) {
                break;
            }
            if (-d $request_filename) {
                break;
            }
            rewrite ^(.+)$ /index.php?q=$1 last;
        }

        location ~ .*\.php[345]?$ {
            include __ROOT__/fastcgi_params;
            fastcgi_pass 127.0.0.1:__PHP_FCGI_PORT__;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME __ROOT__/html/app/webroot$fastcgi_script_name;
        }

    }

}


# vim:filetype=nginx