I'm working on a site that is hosted on pantheon platform, that doesn't use apache webserver.
So I'm thinking wrong or I can't use this module?



spotzero’s picture

Status: Active » Needs work

Pantheon looks like it's using Nginx, which would work if someone ported the Apache rewrite rules to nginx configuration. However, since Pantheon is a packaged hosting solution, you probably won't have the access you'd need to set it up yourself.

If you're keen on using this module with Pantheon, you should contact the Pantheon support people and ask them about integrating it. If they're interested in supporting it or if it is possible for you to set it up, I have no problem developing and maintaining the necessary Nginx conf/rules as part of this module.

However, its more likely that you're best bet is to check out one of the other adaptive image modules.


sk33lz’s picture

I use Nginx on this site, and didn't even seem to have to setup a redirect for it to work properly from what I can tell.

I ran the Apache rewrite rules through a tool I use to convert htaccess rules to Nginx rules for good measure, and this is what I came up with.

# AIS: Adaptive Image Style Configuration 

location = /modules/image/sample.png { 

location / { 
  if ($request_uri ~ "^(.+)/files/styles/adaptive/(.+)$"){ 
    rewrite ^/(.+)/files/styles/adaptive/(.+)$ /$1/files/styles/%1/$2 redirect; 
sk33lz’s picture

One thing I notice is that even if I have this rule set, the module doesn't know it's set properly. Perhaps with the rule above you can put in a check against Nginx rules similar to the .htaccess rules.

spotzero’s picture

Hey sk33lz, thanks for the help, but there is no way those nginx rules work correctly.

The %1 part of:
rewrite ^/(.+)/files/styles/adaptive/(.+)$ /$1/files/styles/%1/$2 redirect;
comes from the user's 'AIS' cookie, so this definitely won't do what it needs to. The rules should also check if the cookie exists before rewriting.

To any Nginx users, do not use the configuration above.

That said, I really do appreciate that you posted this. Thanks for your help.

likewhoa’s picture

Status: Needs work » Needs review


location ~* /(?:.+)/files/styles/adaptive/(?:.+)$ {
  if ( $http_cookie ~* "ais=(?<ais_cookie>[a-z0-9-_]+)" ) {
    rewrite ^/(.+)/files/styles/adaptive/(.+)$ /$1/files/styles/$ais_cookie/$2 last;
  access_log off;
  add_header X-Header "AIS Generator 1.0";
  set $nocache_details "Skip";
  try_files  $uri @drupal;

work for you?

spotzero’s picture

Is this from the octopus project?

It looks like they wrote an nginx solution months ago and never told me (http://drupal.org/node/1452732).

Does it work?


likewhoa’s picture

@spotzero not sure it works but will be testing it out today. I will report back.

spotzero’s picture

Status: Needs review » Closed (works as designed)

Comment 5 seems to work.

graytoby’s picture

Issue summary: View changes
Status: Closed (works as designed) » Active

These rules for Nginx don't work for me. I've tried a few different configs and no luck. Image styles are not being generated, and Nginx serves full images regardless of screen size and device.

graytoby’s picture

Ok, I've found a solution. These rules do work, if placed before any other image styles rules. I'm using Perusio config and was pasting these after location ~* /files/styles/ block. Moving it before solved my issue. I guess this should be mentioned in documentation.

likewhoa’s picture

Status: Active » Closed (works as designed)

@spotzero ma bad, I totally forgot to report back here. Glad it's closed now.