diff --git a/apps/drupal/drupal_js.conf b/apps/drupal/drupal_js.conf new file mode 100644 index 00000000..52448ff5 --- /dev/null +++ b/apps/drupal/drupal_js.conf @@ -0,0 +1,21 @@ +# -*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*- + +### Drupal 7 configuration for the JS Callback Handler module: +### https://www.drupal.org/project/js +location ~* "^/(?:[a-z]{2}(?:-[A-Za-z]{2,4})?/)?(?:js|js/.*)$" { + rewrite ^/(.*)$ /js.php?q=$1 last; +} + +### Non-clean URLs (query based, only uncomment if needed). +# if ($query_string ~ "(?:^|&)q=((?:[a-z]{2}(?:-[A-Za-z]{2,4})?/)?(?:js|js/.*))") { +# rewrite ^/(.*)$ /js.php?q=$1 last; +#} + +location ^~ /js.php { + tcp_nopush off; + keepalive_requests 0; + access_log off; + try_files $uri =404; ### check for existence of php file first + include apps/drupal/fastcgi_js.conf; + fastcgi_pass phpcgi; +} diff --git a/apps/drupal/fastcgi_js.conf b/apps/drupal/fastcgi_js.conf new file mode 100644 index 00000000..4d56cfd9 --- /dev/null +++ b/apps/drupal/fastcgi_js.conf @@ -0,0 +1,47 @@ +#-*- mode: nginx; mode: flyspell-prog; ispell-local-dictionary: "american" -*- + +### Drupal 7 configuration for the JS Callback Handler module: +### https://www.drupal.org/project/js + +### fastcgi configuration for serving private files. +## 1. Parameters. +fastcgi_param QUERY_STRING q=$uri&$args; +fastcgi_param REQUEST_METHOD $request_method; +fastcgi_param CONTENT_TYPE $content_type; +fastcgi_param CONTENT_LENGTH $content_length; + +fastcgi_param SCRIPT_NAME /js.php; +fastcgi_param REQUEST_URI $request_uri; +fastcgi_param DOCUMENT_URI $document_uri; +fastcgi_param DOCUMENT_ROOT $document_root; +fastcgi_param SERVER_PROTOCOL $server_protocol; + +fastcgi_param GATEWAY_INTERFACE CGI/1.1; +fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; + +fastcgi_param REMOTE_ADDR $remote_addr; +fastcgi_param REMOTE_PORT $remote_port; +fastcgi_param SERVER_ADDR $server_addr; +fastcgi_param SERVER_PORT $server_port; +fastcgi_param SERVER_NAME $server_name; +## PHP only, required if PHP was built with --enable-force-cgi-redirect +fastcgi_param REDIRECT_STATUS 200; +fastcgi_param SCRIPT_FILENAME $document_root/js.php; +## HTTPS 'on' parameter. This requires Nginx version 1.1.11 or +## later. The if_not_empty flag was introduced in 1.1.11. See: +## http://nginx.org/en/CHANGES. If using a version that doesn't +## support this comment out the line below. +fastcgi_param HTTPS $fastcgi_https if_not_empty; +## For Nginx versions below 1.1.11 uncomment the line below after commenting out the above. +#fastcgi_param HTTPS $fastcgi_https; + +## 2. Nginx FCGI specific directives. +fastcgi_buffers 256 4k; +fastcgi_intercept_errors on; +## Allow 4 hrs - pass timeout responsibility to upstream. +fastcgi_read_timeout 14400; +fastcgi_index js.php; +## Hide the X-Drupal-Cache header provided by Pressflow. +fastcgi_hide_header 'X-Drupal-Cache'; +## Hide the Drupal 7 header X-Generator. +fastcgi_hide_header 'X-Generator'; diff --git a/sites-available/example.com.conf b/sites-available/example.com.conf index 9da0cd24..8aee8326 100644 --- a/sites-available/example.com.conf +++ b/sites-available/example.com.conf @@ -38,12 +38,6 @@ server { return 444; } - ## Protection against illegal HTTP methods. Out of the box only HEAD, - ## GET and POST are allowed. - if ($not_allowed_method) { - return 405; - } - ## Filesystem root of the site and index. root /var/www/sites/example.com; index index.php; @@ -61,6 +55,20 @@ server { location ~* ^/.well-known/ { allow all; } + + ################################################################# + ### Configuration for Drupal 7 sites that use the JS Callback + ### Handler module: https://www.drupal.org/project/js. This + ### should be above the $not_allowed_method (since the JS module + ### handles these) and above the normal drupal.conf include. + ################################################################# + include apps/drupal/drupal_js.conf; + + ## Protection against illegal HTTP methods. Out of the box only HEAD, + ## GET and POST are allowed. + if ($not_allowed_method) { + return 405; + } ################################################################ ### Generic configuration: for most Drupal 7 sites. @@ -209,6 +217,14 @@ server { return 444; } + ################################################################# + ### Configuration for Drupal 7 sites that use the JS Callback + ### Handler module: https://www.drupal.org/project/js. This + ### should be above the $not_allowed_method (since the JS module + ### handles these) and above the normal drupal.conf include. + ################################################################# + include apps/drupal/drupal_js.conf; + ## Protection against illegal HTTP methods. Out of the box only HEAD, ## GET and POST are allowed. if ($not_allowed_method) {