Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
upstream fpm_example.com1{
server unix:/var/run/php5-fpm.sock;
server unix:/var/run/php5-fpm1.sock;
keepalive 128;
}
upstream admin {
server unix:/var/run/php5-fpm1.sock;
server unix:/var/run/php5-fpm2.sock;
keepalive 128;
}
server {
listen 80;
port_in_redirect off;
root /home/example.com/public_html;
index index.php index.html index.htm;
server_name example.co
client_max_body_size 20m;
client_body_buffer_size 2m;
#logs
# access_log off;
access_log /home/example.com/logs/access.log;
error_log /home/example.com/logs/error.log warn;
location ~ ^/(status|ping)$ {
access_log off;
auth_basic "Restricted";#For Basic Auth
auth_basic_user_file /home/example.com/.htpasswd;
include fastcgi_params;
fastcgi_pass fpm_example.com1;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.php?q=$uri&args;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~ ^/wp-admin/.*\.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_read_timeout 150;
fastcgi_pass admin;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_max_temp_file_size 0;
fastcgi_buffer_size 4K;
fastcgi_buffers 64 4k;
# send bad requests to 404
fastcgi_intercept_errors on;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location /nstatus{
stub_status on;
access_log off;
}
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_read_timeout 150;
fastcgi_pass fpm_example.com1;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_max_temp_file_size 0;
fastcgi_buffer_size 4K;
fastcgi_buffers 64 4k;
# send bad requests to 404
fastcgi_intercept_errors on;
}
location ~ .(jpe?g|png|gif)$ {
valid_referers none blocked example.com;
if ($invalid_referer) {
return 403;
}
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
#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;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
location ~ /\.git {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment