Skip to content

Instantly share code, notes, and snippets.

@dordenis
Created October 9, 2012 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dordenis/3859463 to your computer and use it in GitHub Desktop.
Save dordenis/3859463 to your computer and use it in GitHub Desktop.
server {
listen 78.46.77.145;
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/kupi.ru/current;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name kupi.ru *.kupi.ru;
if ($host ~ "^(.*).kupidev.ru") {
set $category $1;
rewrite ^(.*) /shop/$category$1 last;
}
# ROUTING TO KOHANA IF REQUIRED
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ @kohana;
}
# BLOCKS ACCESS TO . FILES (.svn, .htaccess, ...)
location ~ /\. {
deny all;
}
#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/share/nginx/www;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
# PHP FILES MIGHT BE TO HANDLED BY KOHANA
try_files $uri $uri/ @kohana;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# HANDLES THE REWRITTEN URLS TO KOHANA CONTROLLER
location @kohana {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
}
# CACHE CONTROL FOR STATIC FILES
location ~* \.css|\.js|\.jpg|\.jpeg|\.png|\.gif|\.swf|\.svg|\.tiff|\.pdf$ {
expires 30d;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment