3 # The configuration is based on official Nginx recipe.
4 # See https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/
5 # Check out Perusio's config for more delicate configuration.
6 # See https://github.com/perusio/drupal-with-nginx
9 server_name {{ server_name }};
12 client_max_body_size 16m;
14 location = /favicon.ico {
19 location = /robots.txt {
25 # Very rarely should these ever be accessed.
26 location ~* \.(make|txt|log|engine|inc|info|install|module|profile|po|pot|sh|sql|test|theme)$ {
30 location ~ \..*/.*\.php$ {
34 {% if file_private_path %}
35 location ~ ^/{{ file_private_path }}/ {
40 # Allow "Well-Known URIs" as per RFC 5785.
41 location ~* ^/.well-known/ {
45 # Block access to "hidden" files and directories whose names begin with a
46 # period. This includes directories used by version control systems such
47 # as Subversion or Git to store control files.
53 try_files $uri /index.php?$query_string;
57 rewrite ^/(.*)$ /index.php?q=$1;
60 # Don't allow direct access to PHP files in the vendor directory.
61 location ~ /vendor/.*\.php$ {
66 # In Drupal 8, we must also match new paths where the '.php' appears in
67 # the middle, such as update.php/selection. The rule we use is strict,
68 # and only allows this pattern with the update.php front controller.
69 # This allows legacy path aliases in the form of
70 # blog/index.php/legacy-path to continue to route to Drupal nodes. If
71 # you do not have any paths like that, then you might prefer to use a
72 # laxer rule, such as:
73 # location ~ \.php(/|$) {
74 # The laxer rule will continue to work if Drupal uses this new URL
75 # pattern with front controllers other than update.php in a future
77 location ~ '\.php$|^/update.php' {
78 fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
79 # Security note: If you're running a version of PHP older than the
80 # latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
81 # See http://serverfault.com/q/627903/94922 for details.
82 include fastcgi_params;
83 # Block httpoxy attacks. See https://httpoxy.org/.
84 fastcgi_param HTTP_PROXY "";
85 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
86 fastcgi_param PATH_INFO $fastcgi_path_info;
87 fastcgi_intercept_errors on;
88 fastcgi_pass {{ fastcgi_pass }};
91 # Fighting with Styles? This little gem is amazing.
92 location ~ ^/{{ file_public_path }}/styles/ {
93 try_files $uri @rewrite;
96 # Handle private files through Drupal.
97 location ~ ^/system/files/ {
98 try_files $uri /index.php?$query_string;
101 location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {