Skip to content

fix: enable mod_headers and mod_expires Apache modules by default#244

Merged
AaronFeledy merged 3 commits intomainfrom
test/mod-headers-expires
Mar 8, 2026
Merged

fix: enable mod_headers and mod_expires Apache modules by default#244
AaronFeledy merged 3 commits intomainfrom
test/mod-headers-expires

Conversation

@AaronFeledy
Copy link
Member

@AaronFeledy AaronFeledy commented Mar 8, 2026

What

Enables mod_headers and mod_expires Apache modules by default for all php-apache services.

The problem

The php plugin's Apache startup command only enabled mod_rewrite:

sh -c 'a2enmod rewrite && apache2-foreground'

Neither mod_headers nor mod_expires were activated, even though they're available in the Debian php-apache image. This caused silent failures — .htaccess directives wrapped in <IfModule> guards (like Drupal's own .htaccess) would simply do nothing.

This affects every recipe that uses via: apache: Drupal, WordPress, Laravel, Backdrop, Joomla, Symfony, etc.

The fix

sh -c 'a2enmod rewrite headers expires && apache2-foreground'

Changes

  • builders/php.js: Added headers and expires to the a2enmod command
  • CHANGELOG.md: Added entry for the fix
  • examples/8.4/.htaccess: Test fixture that sets X-Lando-Test: blazes header and enables expires
  • examples/8.4/README.md: Verification commands that curl for those response headers

Related


Note

Medium Risk
Changes the default Apache module set for all via: apache PHP services, which can alter runtime header/caching behavior for apps with existing .htaccess rules. Low implementation complexity, but broad impact across recipes using Apache.

Overview
Apache-based PHP services now start with mod_headers and mod_expires enabled by default by extending the a2enmod startup command in builders/php.js.

Adds an examples/8.4/.htaccess fixture plus README curl checks to verify the modules are active, and records the behavior change in CHANGELOG.md.

Written by Cursor Bugbot for commit cedbfb5. This will update automatically on new commits. Configure here.

Adds .htaccess to 8.4 example that sets a custom header via mod_headers
and enables mod_expires. Both tests expected to fail since the php-apache
startup command only runs 'a2enmod rewrite'.

Refs: lando/lando#976, #243
@netlify
Copy link

netlify bot commented Mar 8, 2026

Deploy Preview for lando-php ready!

Name Link
🔨 Latest commit cedbfb5
🔍 Latest deploy log https://app.netlify.com/projects/lando-php/deploys/69accd21be96c1000701dbbc
😎 Deploy Preview https://deploy-preview-244--lando-php.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 81 (🔴 down 9 from production)
Accessibility: 98 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

The php-apache startup command only enabled mod_rewrite. This meant
mod_headers and mod_expires were available in the Debian image but
never activated, causing silent failures for .htaccess directives
that depend on them (CORS headers, caching, security headers).

This affects every recipe using via: apache (Drupal, WordPress,
Laravel, Backdrop, etc).

Closes #243
Refs: lando/lando#976
@AaronFeledy AaronFeledy changed the title test: add mod_headers and mod_expires verification tests fix: enable mod_headers and mod_expires Apache modules by default Mar 8, 2026
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

Successfully merging this pull request may close these issues.

Enable mod_headers by default

1 participant