When you start one of your Lando projects with lando start
it will perform a health check of all your localhost and proxy URLs. After some recent update to Lando 3.14 at our company Ideenreich we recognized that these checks took much longer then before and often finally failed. It took up to one minute until they finished.
We found out that the reason for this was that our apps returned a 401 HTTP status code (Unauthorized) when Lando tried to access the root URL of our apps (/). As this is not a succesful status code for Lando it retried the check up to 25 times.
To get back the startup speed we had before this we found 2 solutions:
- Disble the checks
- Add 401 to the succesful status codes
Disable the checks
To disable the checks completely you can add a scanner: false
to your .lando file
. For example for our .lando
for our Laravel projects where we use the Lando Laravel recipe we added the following to the services
section:
services:
appserver_nginx:
scanner: false
This is a totally fine solution but we wanted to perform the checks to see if something has gone wrong during the start. That's why we looked for a solution to keep the checks and came up with this second option.
Add 401 to the succesful status codes
By default the checks will pass for any valid 2XX, 3XX and 404 status code. We were looking for a way to tell Lando that 401 should pass for us too. It turned out there is a easy way. Again, you can just add it to the services
section of your .lando
file. In our projects this looks like this:
services:
appserver_nginx:
scanner:
okCodes:
- 401
As you can see you can add as many ok codes as you like:
services:
appserver_nginx:
scanner:
okCodes:
- 401
- 402
- 403
This was the solution we went with for our projects. But there are more options to tackle this problem and to configure the scanner to your needs.
Additional scanner options
Scanning a different path
You can change the path that get's scanned. By default Lando will scan the root path (/) of your project. To change this for example to the /login route you can add the following to the services
section of your .lando
file:
services:
appserver_nginx:
scanner:
path: /login
Setting the timeout and retries
As mentioned before the scanner tries your path 25 times by default if it does not get a ok status code. You can change this and the timeout for a request with the following section in your .lando
file:
services:
appserver_nginx:
scanner:
timeout: 1000
retry: 5
This will set the timeout to 1000 ms and the retries to 5.
Using the legacy scanner
If none of this options is for you you can tell Lando to use the legacy scanner used before version 3.14.0 by adding the following to your .lando
file:
services:
appserver_nginx:
scanner: legacy
If you want to get started with Lando and Laravel you can check out my in-depth blog post about it here. If you have any questions about how we use Lando at our company Ideenreich feel free to contact me on Twitter or by mail.