Pull merge.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / other / nginx-virtual-host.twig
1 #
2 # @DCG
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
7 #
8 server {
9     server_name {{ server_name }};
10     root {{ docroot }};
11
12     client_max_body_size 16m;
13
14     location = /favicon.ico {
15         log_not_found off;
16         access_log off;
17     }
18
19     location = /robots.txt {
20         allow all;
21         log_not_found off;
22         access_log off;
23     }
24
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)$ {
27         return 404;
28     }
29
30     location ~ \..*/.*\.php$ {
31         return 404;
32     }
33
34 {% if file_private_path %}
35     location ~ ^/{{ file_private_path }}/ {
36         return 403;
37     }
38
39 {% endif %}
40     # Allow "Well-Known URIs" as per RFC 5785.
41     location ~* ^/.well-known/ {
42         allow all;
43     }
44
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.
48     location ~ (^|/)\. {
49         return 404;
50     }
51
52     location / {
53         try_files $uri /index.php?$query_string;
54     }
55
56     location @rewrite {
57         rewrite ^/(.*)$ /index.php?q=$1;
58     }
59
60     # Don't allow direct access to PHP files in the vendor directory.
61     location ~ /vendor/.*\.php$ {
62         deny all;
63         return 404;
64     }
65
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
76     # release.
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 }};
89     }
90
91     # Fighting with Styles? This little gem is amazing.
92     location ~ ^/{{ file_public_path }}/styles/ {
93         try_files $uri @rewrite;
94     }
95
96     # Handle private files through Drupal.
97     location ~ ^/system/files/ {
98         try_files $uri /index.php?$query_string;
99     }
100
101     location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
102         expires max;
103         log_not_found off;
104     }
105 }