Drupal, Lando, S3FS module, and Image Styles

The bug: Image styles don’t generate (they all return 404) when using the following:

So you’ll need to override lando’s default vhosts file. You can do so by doing the following in your .lando.yml file.

name: projectname
recipe: drupal9
config:
  via: nginx
  config:
    vhosts: lando/default.conf

Then you’ll need to create a file in your app root lando/default.conf . To start, you can go to the lando/drupal recipe page , go into the recipe you’re using, and then copy the default.conf.tpl into your lando/default.conf file.

Next, locate the following snippet:

  # Fighting with Styles? This little gem is amazing.
  # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
  location ~ ^(/[a-z\-]+)?/sites/.*/files/styles/ { # For Drupal >= 7
      try_files $uri @rewrite;
  }

And replace it with the following snippet (only regex is changed)

  # Fighting with Styles? This little gem is amazing.
  # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
  location ~ '^(/[a-z\-]+)?/sites/.*/files/styles/|^/s3/files/styles/' { # For Drupal >= 7
      try_files $uri @rewrite;
  }

I also opened a GitHub issue in case someone on the project wanted to commit back to the project. I may get around to it if I have time.

Hope this helps. I spent a couple hours on this since I didn’t know why my image styles weren’t generating and I couldn’t find anyone else that was running into the same problem. Good luck!