Created
September 21, 2016 16:58
-
-
Save andrefy/948bff670b83a4702f74502b051f9037 to your computer and use it in GitHub Desktop.
Drupal Nginx settings
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
#Specify a charset | |
charset utf-8; | |
# set client body size to 2M # | |
client_max_body_size 2M; | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
location ~ \..*/.*\.php$ { | |
return 403; | |
} | |
location ~ ^/sites/.*/private/ { | |
return 403; | |
} | |
# Allow "Well-Known URIs" as per RFC 5785 | |
location ~* ^/.well-known/ { | |
allow all; | |
} | |
# Block access to "hidden" files and directories whose names begin with a | |
# period. This includes directories used by version control systems such | |
# as Subversion or Git to store control files. | |
location ~ (^|/)\. { | |
return 403; | |
} | |
location / { | |
try_files $uri /index.php?$query_string; # For Drupal >= 7 | |
} | |
location @rewrite { | |
rewrite ^/(.*)$ /index.php?q=$1; | |
} | |
# Don't allow direct access to PHP files in the vendor directory. | |
location ~ /vendor/.*\.php$ { | |
deny all; | |
return 404; | |
} | |
# Enable PHP | |
include /usr/local/etc/nginx/jessie/location/php.conf; | |
# Fighting with Styles? This little gem is amazing. | |
location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7 | |
try_files $uri @rewrite; | |
} | |
# Handle private files through Drupal. | |
location ~ ^/system/files/ { # For Drupal >= 7 | |
try_files $uri /index.php?$query_string; | |
} | |
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { | |
expires max; | |
log_not_found off; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment