Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for module js - High-performance JavaScript callback handler #246

Open
heyyoyo opened this issue May 4, 2016 · 2 comments
Open

Comments

@heyyoyo
Copy link

heyyoyo commented May 4, 2016

Need help to modify NGINX configuration to add support for the the module js.

This module allows to use a really light and customized Drupal bootstrap for AJAX callback.
The gain of performance is huge.

To realize that, the module doesn't use index.php form drupal, but its own js.php script that we need to insert inside Drupal root directory.

All AJAX callbacks using this module must start with directory /js/mymodule/callback-name.
Baraccuda provides this modification to their project:
http://cgit.drupalcode.org/sandbox-omega8cc-1074910/commit/?id=1d5141b

###
### Support for http://drupal.org/project/js module.
###
location ^~ /js/ {
  location ~* ^/js/ {
    rewrite ^/(.*)$ /js.php?q=$1 last;
  }
}
@markhalliwell
Copy link

There is now official (https://www.drupal.org/node/2834257) NGINX rewrite rules for the 7.x-2.x branch of the JS Callback Handler module:

###
### Support for https://www.drupal.org/project/js module.
###
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;
#}

It also, currently, adds instructions on how to add support for this project:

### PHP-FPM (using https://github.com/perusio/drupal-with-nginx)
###
### 1. Copy `apps/drupal/fastcgi_drupal.conf` to `apps/drupal/fastcgi_js.conf`.
### 2. Inside `fastcgi_js.conf`, rename all cases of `index.php` to `js.php`.
###
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;
}

In hindsight, it'd be nice if this was automatically supported by this project.

@markhalliwell
Copy link

markhalliwell commented Jan 12, 2017

I actually went ahead and made this a little easier to implement. Existing sites (once that PR is merged) can update to the latest code and just add the following to their site's server code block (before the apps/drupal/drupal.conf include and $not_allowed_method check):

    #################################################################
    ### 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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants