fastcgi_cache_path      /var/tmp/nginx/fastcgi_cache_website    levels=1:2      keys_zone=website:20m max_size=512m inactive=7d;

server {
        listen          192.168.10.80:80;
        listen          192.168.10.80:443;
        server_name     website.com.ua;
        access_log      off;
        error_log       off;
        rewrite ^ http://www.website.com.ua$request_uri permanent;
}

server {
        listen          192.168.10.80:80;
        server_name     www.website.com.ua;

        allow           all;

        access_log      /home/website/logs/website.com.ua_access.log    main;
        error_log       /home/website/logs/website.com.ua_error.log             notice;

        client_max_body_size            20m;
        client_body_buffer_size         128k;
        client_body_temp_path           /home/website/tmp/client_body_temp;

        root    /home/website/docroot/web;
        index   index.php;

        fastcgi_cache_key                               $request_method$host$uri$is_args$args;
        fastcgi_intercept_errors                on;
        fastcgi_index                                   index.php;
        fastcgi_send_timeout                    180;
        fastcgi_read_timeout                    180;
        fastcgi_buffer_size                             128k;
        fastcgi_buffers                                 4 256k;
        fastcgi_busy_buffers_size               256k;
        fastcgi_temp_file_write_size    256k;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                # access_log off;
        }

        location ~ /\.ht {
                deny all;
        }

        location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|xz|lzma|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|wmv|flv|fla|swf|bmp|rtf|js)$ {
                expires max;
        }

        location = / {
                try_files       /maintenance.html       $uri    @rewrite_nc;
        }

        location / {
                try_files       /maintenance.html       $uri    @rewrite_nc;
        }

        location ~ ^/backend.php {
                rewrite ^(.*) https://$host$1 permanent;
        }

        location ~* feedback$ {
                try_files       /maintenance.html       $uri    @rewrite_nc;
        }

        location ~* (pidpiska|podpiska|subscribe)$ {
                try_files       /maintenance.html       $uri    @rewrite_nc;
        }

        location ~* ^/captcha {
                try_files       /maintenance.html       $uri    @rewrite_nc;
        }

        location ~* ^/(uk|ru|en) {
                try_files       /maintenance.html       $uri    @rewrite;
        }

        location @rewrite {
                set     $cache  1;
                rewrite ^/(.*)$ /index.php?symphony-page=$1 last;
        }

        location @rewrite_nc {
                set     $cache  0;
                rewrite ^/(.*)$ /index.php?symphony-page=$1 last;
        }

        location ~ \.php$ {
                if ($cache) {
                        error_page      418     =       @symphony;
                        return  418;
                }
                error_page      418     =       @symphony_nc;
                return          418;
        }

        location @symphony_nc {
                include fastcgi_params;
                fastcgi_cache           off;
                fastcgi_param           SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_pass            unix:/home/website/tmp/php-fpm_website.sock;
        }

        location @symphony {
                include fastcgi_params;
                fastcgi_hide_header                     "Set-Cookie";
                fastcgi_ignore_headers          Cache-Control Expires X-Accel-Redirect X-Accel-Expires Set-Cookie;
                fastcgi_cache                           website;
                fastcgi_cache_valid                     200 302         20m;
                fastcgi_cache_valid                     301                     1h;
                fastcgi_cache_valid                     404 502         1m;
                fastcgi_cache_valid                     503                     4s;
                fastcgi_cache_valid                     any                     1h;
                fastcgi_cache_use_stale         error timeout invalid_header updating http_500 http_503;
                fastcgi_param           SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_pass            unix:/home/website/tmp/php-fpm_website.sock;
        }
}

server {
        listen          192.168.10.80:443;

        server_name     www.website.com.ua;

        allow           all;

        ssl                                     on;
        ssl_certificate         /usr/local/etc/ssl/httpd/crt/website.com.ua.crt;
        ssl_certificate_key     /usr/local/etc/ssl/httpd/key/server.key;

        access_log      /home/website/logs/website.com.ua_access.log    main;
        error_log       /home/website/logs/website.com.ua_error.log             notice;

        client_max_body_size            20m;
        client_body_buffer_size         128k;
        client_body_temp_path           /home/website/tmp/client_body_temp;

        root    /home/website/docroot/web;
        index   index.php;

        fastcgi_cache_key                               $request_method$host$uri$is_args$args;
        fastcgi_intercept_errors                on;
        fastcgi_index                                   index.php;
        fastcgi_send_timeout                    180;
        fastcgi_read_timeout                    180;
        fastcgi_buffer_size                             128k;
        fastcgi_buffers                                 4 256k;
        fastcgi_busy_buffers_size               256k;
        fastcgi_temp_file_write_size    256k;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
        }

        location ~ /\.ht {
                deny all;
        }

        location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|xz|lzma|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|wmv|flv|fla|swf|bmp|rtf|js)$ {
                expires max;
        }

        location = / {
                try_files       /maintenance.html       $uri    @rewrite_nc;
        }

        location / {
                try_files       /maintenance.html       $uri    @rewrite_nc;
        }

        location ~* feedback$ {
                try_files       /maintenance.html       $uri    @rewrite_nc;
        }

        location ~* (pidpiska|podpiska|subscribe)$ {
                try_files       /maintenance.html       $uri    @rewrite_nc;
        }

        location ~* ^/captcha {
                try_files       /maintenance.html       $uri    @rewrite_nc;
        }

        location ~* ^/(uk|ru|en) {
                try_files       /maintenance.html       $uri    @rewrite;
        }

        location @rewrite {
                set     $cache  1;
                rewrite ^/(.*)$ /index.php?symphony-page=$1 last;
        }

        location @rewrite_nc {
                set     $cache  0;
                rewrite ^/(.*)$ /index.php?symphony-page=$1 last;
        }

        location ~ \.php$ {
                if ($cache) {
                        error_page      418     =       @symphony;
                        return  418;
                }
                error_page      418     =       @symphony_nc;
                return          418;
        }

        location ~ ^/backend.php {
                rewrite ^/(.*)$ /backend.php?symphony-page=$1&mode=administration last;
                error_page      418     =       @symphony_nc;
                return          418;
        }

        location @symphony_nc {
                include fastcgi_params;
                fastcgi_cache           off;
                fastcgi_param           SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param           HTTPS   on;
                fastcgi_pass            unix:/home/website/tmp/php-fpm_website.sock;
        }

        location @symphony {
                include fastcgi_params;
                fastcgi_hide_header                     "Set-Cookie";
                fastcgi_ignore_headers          Cache-Control Expires X-Accel-Redirect X-Accel-Expires Set-Cookie;
                fastcgi_cache                           website;
                fastcgi_cache_valid                     200 302         20m;
                fastcgi_cache_valid                     301                     1h;
                fastcgi_cache_valid                     404 502         1m;
                fastcgi_cache_valid                     503                     4s;
                fastcgi_cache_valid                     any                     1h;
                fastcgi_cache_use_stale         error timeout invalid_header updating http_500 http_503;
                fastcgi_param           SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param           HTTPS   on;
                fastcgi_pass            unix:/home/website/tmp/php-fpm_website.sock;
        }
}
