Welcome! Log In Create A New Profile

Advanced

Tricky configuration rewrite rules (Symfony+FastCGI+Cache)

Posted by cat_crash 
Tricky configuration rewrite rules (Symfony+FastCGI+Cache)
July 10, 2012 01:33PM
Hello, dear community.

due several unsuccessful attempts to solve problem - I require your help.
I have production server with NGINX onboard and due high load there is requirement to setup cache up 2 minutes.
On first sight everything fine except one thing: Pages in user account (URL starts with: /account/* )also cached and all changes displayed only after 2 minutes whitch is not good and user friendly.

I try to make configuration like

location ^~ /accounts/ {
...
try_files $uri /index.php?$args;
}
and face problem with cache because of it's pass to rule for whole .php files
if I make
location ^~ /accounts/ {
...
WITHOUT try_files $uri /index.php?$args;
} I recieve error from NGINX: No input file specified


Please, help me with this war!
Thanks and looking forward for your kindness

My Config (with highlight: http://pastebin.com/GurMXw1b)

server {
listen *:80;
server_name .map.by;
access_log /var/log/nginx/access.log;

root /home/mapby/www/web;
index index.php index.html index.htm;

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9090
#

if ($host = 'gomel.map.by' ) {
rewrite ^/(.*)$ http://map.by/%D0%93%D0%BE%D0%BC%D0%B5%D0%BB%D1%8C$1 permanent;
}


location / {
rewrite "^/minsk_anons/[0-9]{2,4}[0-9]{1,2}[0-9]{1,2}_([0-9]+)\.html$" /834a74fe95a05a05a95d7cfaec9cc494.php;
rewrite ^/news/(.*)\.htm$ /news/$1.html redirect;
index index.php;
try_files $uri /index.php?$args;

}

location /js {
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/html text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml;

# make sure gzip does not lose large gzipped js or css files
# see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl
gzip_buffers 16 8k;

# Disable gzip for certain browsers.
gzip_disable "MSIE [1-6].(?!.*SV1)";
}

location /css {
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/html text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml;

# make sure gzip does not lose large gzipped js or css files
# see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl
gzip_buffers 16 8k;

# Disable gzip for certain browsers.
gzip_disable "MSIE [1-6].(?!.*SV1)";
}

location ^~ /backend.php {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/mapby/www/web$fastcgi_script_name;
fastcgi_param HTTPS off;
fastcgi_pass 127.0.0.1:9000;

fastcgi_cache off;
try_files $uri /backend.php?$args;
}

location ~ \.php$ {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/mapby/www/web$fastcgi_script_name;
fastcgi_param HTTPS off;
fastcgi_pass 127.0.0.1:9000;

fastcgi_pass_header "Set-Cookie";
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_cache_key "$server_addr:$server_port$request_uri|$cookie_phpsessid|$cookie_symfony|$cookie_OAID";
fastcgi_cache fastcgi_cache;
fastcgi_temp_path /var/cache/nginx/ 1 2;
fastcgi_cache_use_stale updating error timeout invalid_header http_500;
fastcgi_cache_valid 120s;
}


location ^~ /frontend_dev.php/ {
try_files $uri /frontend_dev.php?$args;
}


location ^~ /cabinet.php/ {
try_files $uri /cabinet.php?$args;
}

location ^~ /cabinet_dev.php/ {
try_files $uri /cabinet_dev.php?$args;
}

}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 82
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready