Difference between revisions of "Nginx"
From Alessandro's Wiki
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
It is a "free, open-source, high-performance HTTP server and reverse proxy" | |||
| Line 66: | Line 68: | ||
} | } | ||
</pre> | </pre> | ||
= References = | |||
* http://emspace.com.au/article/nginx-rewrite-rules-pathinfo-and-scriptname | |||
* http://wiki.nginx.org/Drupal | |||
* http://klau.si/nginx-configuration-drupal | |||
Latest revision as of 14:47, 1 October 2012
It is a "free, open-source, high-performance HTTP server and reverse proxy"
Configuration
- server { }
listen 80; server_name thedomain.com;
access_log logs/access.log; error_log logs/error.log;
root /home/swin/oaih/dev/public; index index.php index.html index.htm;
- location { }
- not logging if the site icon does not exists:
location = /favicon.ico {
log_not_found off;
access_log off;
}
- denying a directory:
location = /directory_to_hide {
deny all;
}
- allow certain files only to local lan:
location ~* \.(txt|logs)$ {
allow 192.168.0.0/24;
deny all;
}
- block files by extension:
location ~* \.(inc|engine|install|info|module|sh|sql|theme|tpl\.php|xtmpl|Entries|Repository|Root|jar|java|class)$ {
deny all;
}
FastCGI
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~ .php($|/) {
set $script $uri;
set $path_info "";
if ($uri ~ "^(.+.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$script;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param PATH_INFO $path_info;
}
Rewrite rules
- rewriting every non existent file to index.php
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}