#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /usr/local/apps/nginx/var/log/nginx.pid;
events {
worker_connections 1024;
}
error_log /usr/local/apps/nginx/var/log/error_log debug;
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/apps/nginx/var/log/web.access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 30;
keepalive_requests 80;
#gzip on;
client_max_body_size 200M;
# If your domain names are long, increase this parameter.
server_names_hash_bucket_size 64;
# To hide the version number in headers
server_tokens off;
include /usr/local/apps/nginx/etc/conf.d/*.conf;
}
server {
listen XX.XX.XX.XX:80;
server_name mysite.ru;
root /var/www/mysite.ru;
index index.php index.html index.htm;
error_log /var/log/nginx/mysite.ru_error.log;
access_log /var/log/nginx/mysite.ru_access.log main;
set $fastcgipass unix:/var/lib/php5-fpm/mysite.sock;
## Disable .htaccess and other hidden files
location ~* /\.(ht|svn|hg) {
deny all;
access_log off;
log_not_found off;
}
## Disable .gitignore file and .git directory
location ~ (/\.gitignore|/\.git) {
deny all;
access_log off;
log_not_found off;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|exe|xls|doc|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mov)$ {
expires 14d;
access_log off;
log_not_found off;
}
location ~* ^.+\.(css|js)$ {
expires 24h;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* /(images|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
deny all;
access_log off;
log_not_found off;
}
location ~* /wp-content/.*\.php$ {
deny all;
access_log off;
log_not_found off;
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
access_log off;
log_not_found off;
}
location ~ /wp-config.php {
deny all;
access_log off;
log_not_found off;
}
location ~ /xmlrpc.php {
deny all;
access_log off;
log_not_found off;
}
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri @cms;
include /etc/nginx/fastcgi_params;
fastcgi_pass $fastcgipass;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location @cms {
fastcgi_pass $fastcgipass;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
include /etc/nginx/fastcgi_params;
}
}