This is a better Drupal nginx config. Built from a combination of contributions from here:
https://groups.drupal.org/node/305633 https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/
This commit is contained in:
parent
95ef5e1e70
commit
928451ae88
@ -2,27 +2,55 @@ server {
|
|||||||
listen 80;
|
listen 80;
|
||||||
listen [::]:80;
|
listen [::]:80;
|
||||||
|
|
||||||
server_name site_a.dev;
|
#domain name
|
||||||
root /var/www/site_a;
|
server_name drupal8.dev;
|
||||||
index index.php;
|
|
||||||
|
|
||||||
|
#file document root. This has to match one of the volumes in docer-composer.yml
|
||||||
|
root /var/www/drupal8;
|
||||||
|
|
||||||
|
# This is the full path to your index file
|
||||||
|
index index.php index.html index.htm;
|
||||||
|
|
||||||
|
|
||||||
|
## serve imagecache files directly or redirect to drupal if they do not exist.
|
||||||
|
location ~* files/styles {
|
||||||
|
access_log off;
|
||||||
|
expires 30d;
|
||||||
|
try_files $uri @drupal;
|
||||||
|
}
|
||||||
|
|
||||||
|
## serve imagecache files directly or redirect to drupal if they do not exist.
|
||||||
|
location ~* ^.+.(xsl|xml)$ {
|
||||||
|
access_log off;
|
||||||
|
expires 1d;
|
||||||
|
try_files $uri @drupal;
|
||||||
|
}
|
||||||
|
|
||||||
|
## Images and static content is treated different
|
||||||
|
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
|
||||||
|
access_log off;
|
||||||
|
expires 30d;
|
||||||
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ /index.php?q=$uri&$args;
|
index index.php;
|
||||||
|
# This is cool because no php is touched for static content
|
||||||
|
try_files $uri $uri/ @rewrite;
|
||||||
|
expires max;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_page 404 /404.html;
|
location @drupal {
|
||||||
error_page 500 502 503 504 /50x.html;
|
rewrite ^/(.*)$ /index.php?q=$1 last;
|
||||||
location = /50x.html {
|
|
||||||
root /var/www/site_a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ [^/]\.php(/|$) {
|
|
||||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
location @rewrite {
|
||||||
if (!-f $document_root$fastcgi_script_name) {
|
# Some modules enforce no slash (/) at the end of the URL
|
||||||
return 404;
|
# Else this rewrite block wouldn't be needed (GlobalRedirect)
|
||||||
|
rewrite ^/(.*)$ /index.php?q=$1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location ~ .php$ {
|
||||||
fastcgi_pass php-upstream;
|
fastcgi_pass php-upstream;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
Loading…
Reference in New Issue
Block a user