0

I'm trying to install Boost module to work with nginx. As we know Boost does not generate nginx directives just like Apache.

Boost has the following directives for Apache's .htaccess:

  ### BOOST START ###

  # Allow for alt paths to be set via htaccess rules; allows for cached variants (future mobile support)
  RewriteRule .* - [E=boostpath:normal]

  # Caching for anonymous users
  # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR request came from this server OR https request
  RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [OR]
  RewriteCond %{REQUEST_URI} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add|comment/reply))|(/(edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTPS} on [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{ENV:REDIRECT_STATUS} 200
  RewriteRule .* - [S=3]

  # GZIP
  RewriteCond %{HTTP:Accept-encoding} !gzip
  RewriteRule .* - [S=1]
  RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html,E=no-gzip:1]

  # NORMAL
  RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

  ### BOOST END ###

I tried to convert the above code to nginx by using this site to no avail. Here's the converted code that don't work:

# nginx configuration

location / {
  rewrite ^(.*)$ /cache/$env_boostpath/$http_host$request_uri_$query_string\.html;
  rewrite ^(.*)$ /cache/$env_boostpath/$http_host$request_uri_$query_string\.html;
}

Can anyone help me please.

Thank you

0

nginx is not apache. You should be using try_files, not rewrites, for this sort of thing.

For instance, this was ripped out of a very well done sample Drupal nginx configuration:

    try_files /cache/normal/$host${uri}_${args}.html /cache/perm/$host${uri}_.css /cache/perm/$host${uri}_.js /cache/$host/0$uri.html /cache/$host/0${uri}/index.html @drupal;
  • I'm having trouble with perusio's configuration because I am using ispconfig 3. And I am lost with so many configuration. Can you please guide me for the optimal configuration of Boost for nginx? – jaYPabs Jan 26 '14 at 3:31
  • I just did. You would be better off without ispconfig. :) – Michael Hampton Jan 26 '14 at 3:34
  • I tried try_files above but still it doesn't work. I can't work without ispconfig. All of my sites are already using it. – jaYPabs Jan 26 '14 at 3:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.