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

Allow a .htaccess-lando to override .htaccess #38

Open
web-assistant opened this issue May 21, 2020 · 11 comments
Open

Allow a .htaccess-lando to override .htaccess #38

web-assistant opened this issue May 21, 2020 · 11 comments
Assignees
Labels
apache bug Something isn't working

Comments

@web-assistant
Copy link

web-assistant commented May 21, 2020

I'm trying to override the .htaccess file as instructed in https://docs.lando.dev/config/apache.html#configuration. Adding .htaccess-lando next to the Drupal root .htaccess file doesn't do anything. I have tried rebuilding and also tried adding the custom httpd.conf file taken from https://github.com/lando/lando/tree/master/plugins/lando-services/services/apache. Any ideas how I can get this working?

screen

Running Lando v3.0.3 on Windows 10.

name: thingymajig
recipe: drupal7
config:
  php: '7.2'
  via: apache
  webroot: web
  database: mariadb
  drush: ^8
  xdebug: false
  config:
    php: .lando/.lando.php.ini
    database: .lando/.lando.mysql.cnf
    server: .lando/httpd.conf
    vhosts: .lando/default.conf

proxy:
  appserver:
    - thingymajig.lndo.site
    - www.thingymajig.lndo.site
  mailhog:
    - mail.thingymajig.lndo.site
  pma:
    - pma.thingymajig.lndo.site
  adminer:
    - adminer.thingymajig.lndo.site

services:
  database:
    creds:
      database: thingymajig
      user: thingymabob
      password: easylike123
  appserver:
    overrides:
      environment:
        # Support debugging Drush with XDEBUG.
        PHP_IDE_CONFIG: "serverName=appserver"
  mailhog:
    type: mailhog
    hogfrom:
      - appserver
    portforward: true
  pma:
    type: phpmyadmin
    hosts:
      - database
  adminer:
    type: compose
    services:
      image: dehy/adminer
      command: /bin/s6-svscan /etc/services.d
    portforward: true

tooling:
  xon:
    service: appserver
    description: Enable xdebug for apache.
    cmd: "docker-php-ext-enable xdebug && /etc/init.d/apache2 reload"
    user: root
  xoff:
    service: appserver
    description: Disable xdebug for apache.
    cmd: "rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && /etc/init.d/apache2 reload"
    user: root

excludes:
  - .idea
  - .git
@web-assistant web-assistant added the bug Something isn't working label May 21, 2020
@rabauss
Copy link

rabauss commented May 22, 2020

How does your httpd.conf look like?
I guess, it should contain the following line like in the example:
https://github.com/lando/lando/blob/3802a60012fa1938ff3cf2f647c4ad7e1baf72a1/examples/apache/config/httpd.conf#L455

EDIT: I see you took them from the services. Could be a bug in the config - but I've never use that feature before.

@web-assistant
Copy link
Author

@rabauss I changed the httpd.conf to the one in the link you provided but still get the same issue. The docs say that the override should work with the httpd.conf shipped with Lando, though if I have the .htaccess-lando file with no custom httpd.conf it still doesn't work. I'm rebuilding Lando each time.

@hanoii
Copy link

hanoii commented May 24, 2020

Yes, this is not working for me either. Looking at the /etc/apache2/apache2.conf inside the container it doesn't have .htaccess-lando on it

@smutlord smutlord removed their assignment May 26, 2020
@anacolautti
Copy link

anacolautti commented Jun 2, 2020

Hi everyone!
While the experts figure this out (I wish I could help, but actually I know very little of about the subject) I have a temporal fix for anyone who might need this right away.
I was inspired by the issue that enabled this feature to begin with, I tried actually applying their code and it didn't work for me.

This variation of their code did, though:

if [ -e /etc/apache2/apache2.conf ]; then
    if ! grep -e 'AccessFileName .htaccess-lando .htaccess' /etc/apache2/apache2.conf >/dev/null; then
        # force apache to use the .htaccess-lando file
        eval "sed -i 's/AccessFileName .htaccess/AccessFileName .htaccess-lando/g' /etc/apache2/apache2.conf"
    fi
fi

I'm replacing the line in my Apache service that calls my client's .htaccess and calling the file .htaccess-lando instead.
I know this is just temporary, until someone fixes this for real, but in took me a few hours to get this working and I thought I could spare them for someone else.

Just remember to add this code to a script, and call it from your .lando.yml file at the services key like this:

[...]
services:
  myservice:
    build_as_root:
      cmd: /path/temporal_apache_patch.sh
[...]

Keep being awesome!

@stale
Copy link

stale bot commented Apr 27, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

wilsona referenced this issue in uw-drupal/uwdug Aug 19, 2021
Apache looks for `.htaccess` files in the order listed in `AccessFileName`,
reading only the first one it finds. Lando is supposed to change that
list, but it isn't working. See:
https://github.com/lando/lando/issues/2277
This project needs the updated `AccessFileName` list so the `.htaccess`
file on the server can include Shibboleth statements that will cause
errors in Lando, while the local, Lando-specific file, excludes them.
wilsona referenced this issue in uw-drupal/uwdug Aug 19, 2021
Apache looks for `.htaccess` files in the order listed in `AccessFileName`,
reading only the first one it finds. Lando is supposed to change that
list, but it isn't working. See:
https://github.com/lando/lando/issues/2277
This project needs the updated `AccessFileName` list so the `.htaccess`
file on the server can include Shibboleth statements that will cause
errors in Lando, while the local, Lando-specific file, excludes them.
@f-liva
Copy link

f-liva commented Sep 10, 2021

When will this hotfix be implemented natively?

@stale
Copy link

stale bot commented Mar 30, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions and please check out this if you are wondering why we auto close issues.

@reynoldsalec
Copy link
Sponsor Member

...and this is still totally an issue. Taking a look at this after some folks mentioned it on Slack.

@reynoldsalec
Copy link
Sponsor Member

Ok, so in some ways the "root issue" here is one of documentation.

The Lando Apache service accepts a .htaccess-lando file just fine, but virtually no one uses the standalone Lando Apache service. Typically Lando users are using a WordPress/Drupal recipe that leverages Lando's PHP service, and that service actually uses different Dockerfiles to generate the Apache server, which do not make the changes to httpd.conf necessary to read the .htaccess-lando file.

That said, I think we've had enough consistent interest/confusion in this feature that it should be added to the PHP service.

I'm moving this ticket to the lando/php project, steps for implementation are to...

  1. Create custom httpd.conf with the line AccessFileName .htaccess-lando .htaccess
  2. Make sure that custom config file is copied to the correct location via the Dockerfile (probably /etc/apache2/apache2.conf)
  3. Add tests to the PHP service, similar to the ones on the Apache service testing the custom .htaccess file

@reynoldsalec reynoldsalec transferred this issue from lando/apache May 23, 2022
@reynoldsalec reynoldsalec changed the title .htaccess-lando not overriding .htaccess Allow a .htaccess-lando to override .htaccess May 23, 2022
@reynoldsalec
Copy link
Sponsor Member

...also noting that when we re-do the PHP service, we should have it consume the Lando Apache service.

@yorkshire-pudding
Copy link

Thanks @anacolautti for documenting the workaround.
It works a treat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apache bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants