I can't take credit. Adam Lewis - awesome dev created one and I've taken what he's done.
Last active
April 12, 2018 20:18
-
-
Save gemmadlou/eebeeb4bcbdc1892fb37d36d0fec2924 to your computer and use it in GitHub Desktop.
nginx Example config for wp
This file contains hidden or 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 80; | |
| server_name somesite.com; | |
| root /var/www/vhosts/somewebsite/public; | |
| # pass the PHP scripts to FastCGI server | |
| # | |
| # See conf.d/php-fpm.conf for socket configuration | |
| # | |
| index index.php index.html index.htm; | |
| location ~ \.php$ { | |
| try_files $uri =404; | |
| fastcgi_intercept_errors on; | |
| fastcgi_index index.php; | |
| include fastcgi_params; | |
| fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
| fastcgi_pass php-fpm; | |
| } | |
| # WordPressy stuff | |
| # Deny access to any files with a .php extension in the uploads directory | |
| # Works in sub-directory installs and also in multisite network | |
| # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) | |
| location ~* /(?:uploads|files)/.*\.php$ { | |
| deny all; | |
| } | |
| location / { | |
| index index.php index.html index.htm; | |
| try_files $uri $uri/ /index.php?$args; | |
| } | |
| # Caching | |
| location ~* \.(js|css|png|jpg|jpeg|gif|ico|woff|woff2|svg)$ { | |
| expires max; | |
| log_not_found off; | |
| } | |
| # Global restrictions configuration file. | |
| # Designed to be included in any server {} block. | |
| location = /favicon.ico { | |
| log_not_found off; | |
| access_log off; | |
| } | |
| location = /robots.txt { | |
| allow all; | |
| log_not_found off; | |
| access_log off; | |
| } | |
| # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). | |
| # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) | |
| location ~ /\. { | |
| deny all; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment