Created
December 8, 2017 06:08
-
-
Save CHERTS/1abf3b712c0ec55c8060b66b7b773006 to your computer and use it in GitHub Desktop.
Minimal Nginx config file to WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment