lando / docs

The main docs site for Lando
https://docs.lando.dev/
GNU General Public License v3.0
20 stars 56 forks source link

Subdomains do not work [SOLVED] #54

Closed milkovsky closed 5 years ago

milkovsky commented 5 years ago

Subdomains do not work for me. I see only 404 page not found on the page.

OS: Ubuntu 18.04.2 LTS lando version: v3.0.0-rc.14 docker --version: Docker version 18.09.4, build d14af54266

Test 1: As suggested in https://docs.devwithlando.io/config/proxy.html#sub-subdomains I have used a hypenated subdomain. Content of the lando.yml:

name: mysite
recipe: drupal8

config:
  webroot: docroot

proxy:
  appserver:
    - ch-mysite.lndo.site
  1. lando start.
  2. See the both htts and https ch-mysite.lndo.site URLS in red color.
  3. Visit https://ch-mysite.lndo.site in browser
  4. Accept the certificate
  5. See 404 page not found

Test 2: Content of the lando.yml:

name: mysite
recipe: drupal8

config:
  webroot: docroot

proxy:
  appserver:
    - mysite.lndo.site
    - ch.mysite.lndo.site
    - ch-mysite.lndo.site
    - '*.mysite.lndo.site'
  1. lando start.
  2. See all the URLs with subdomains hypenated subdomains and in red color.
  3. Visit any subdomain page in browser
  4. Accept the certificate
  5. See 404 page not found

In addition I have tried to run lando start -vvv and I see:

info: Checking to see if https://ch.mysite.lndo.site is ready.
info: Checking to see if https://ch-mysite.lndo.site is ready.
verbose: https://ch.mysite.lndo.site not currently accessible
verbose: https://ch-mysite.lndo.site not currently accessible

Related issues: https://github.com/lando/lando/issues/1230 https://github.com/lando/lando/issues/618 https://github.com/lando/wordpress/issues/38

Solution: Update lando version to v3.0.0-rc.17.

ericbkennedy commented 5 years ago

I have also run into this bug with WordPress multisites running under landov 3.0.0-rc.14 using the pantheon wordpress recipe. (Those multisites run fine on Pantheon, so the config issue seems limited to lando.) Sites other than the main one all return 404s whether they are true subdomains (sub.domain.lndo.site), or whether I try to change all of the hyphenated subdomain (sub-domain.lndo.site). I've tried putting the proxy lines under appserver and appserver_nginx and tried wildcards but the result is always a 404 for the secondary sites.

Wordpress normally configures multisites as subdomains (the alternative is a subdirectory), which might require accepting a separate certificate for the subdomain (e.g. sub.domain.lndo.site) but it would be better to accept a second certificate and have secondary sites load than not support multi-sites at all. So if Wordpress isn't able to handle the hyphenated subdomains, then we need support for the traditional subdomain (sub.domain.lndo.site). Thank you.

ericbkennedy commented 5 years ago

A colleague found a fix for this -- each site URL must be listed under edge instead of appserver despite the other docs online, e.g.

recipe: wordpress
config:
  framework: wordpress
  site: mysite
# Multisites must have each site listed below to work under lando
# and the URLs must match those in the wp_blogs table
proxy:
  edge:
    - mysite.lndo.site
    - secondary-mysite.lndo.site

So the docs that suggest to have the proxy entries under appserver need to be updated.

milkovsky commented 5 years ago

@ericbkennedy, thank you for the feedback. Unfortunately this does not work with recipe: drupal8.

error: edge is a service that does not exist in your app!!!

You can see the available services with lando info.

forgenator commented 5 years ago

Hi, we had the same problem with recipe: drupal7 and the correct service is appserver_nginx.

So:

proxy:
  appserver_nginx:
   - domain1.tld
   - domain2.tld

Note, you need to add all the domains you want to have routed, also the "default" one, that is usually added automatically based on project name.

milkovsky commented 5 years ago

Thank you, I still get the error:

error: appserver_nginx is a service that does not exist in your app!!!

As mentioned in https://github.com/lando/lando/issues/1584#issuecomment-486602026, lando info gives information about the available services. You can also see them listed when you start lando. For recipe: drupal8 the services are: appserver, database.

pirog commented 5 years ago

@milkovsky has the important comment here at https://github.com/lando/lando/issues/1584#issuecomment-488579530

Due to the complexity of what Lando can do there are instances where the service that actually serves your application is not appserver but some other service like a Varnish edge or nginx appserver_nginx. We definitely recommend you run lando info to determine which service is actually serving your application especially if you are running an application with a complex topology.

If you've run lando info and you feel like you are using the correct service then its worth making sure your application does not have any program logic that could result in a 404 eg the application does not know how to route requests from certain domains.

Going to kick this issue back for now but guessing it might end up as a documentation improvement.

stale[bot] commented 5 years ago

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.

milkovsky commented 5 years ago

The issue is still relevant. I can not create sub-domains in my Lando setup. The documentation improvement might help.

quicksketch commented 5 years ago

@milkovsky I was experiencing the exact same issue. drupal8 recipe and the proxy settings not working for the appserver service, and I was getting the generic 404 page not found error from the proxy service. I updated from 3.0.0-rc.6 to the latest (3.0.0-rc.17) Lando, and used lando rebuild on my project. And now my subdomains are getting picked up properly.

Entire contents of my .lando.yml are as follows:

name: example
recipe: drupal8
config:
  webroot: .
proxy:
  appserver:
    - example1.lndo.site
    - example2.lndo.site
milkovsky commented 5 years ago

@quicksketch thank you for the answer. I have updated lando to v3.0.0-rc.17. After lando rebuild everything works. There is no 404 error anymore, the URLs are green after lando start.

Lando version: v3.0.0-rc.17 Docker version: 18.09.6, build 481bc77

My lando.yml:

name: example
recipe: drupal8

proxy:
  appserver:
    - example.lndo.site
    - de.example.lndo.site
pirog commented 5 years ago

Nice! Thanks @quicksketch for the assist!

If you guys think this is something we could handle better please submit another issue with stepz to replicate!

kamalkech commented 5 years ago
lando version v3.0.0-rc.17
docker version 19.03.1-ce

and file .lando.yml

name: example
recipe: drupal8
proxy:
  appserver:
    - example.lndo.site
    - de.example.lndo.site
config:
  webroot: .
  via: nginx

that s not wokring for me, any idea ?

milkovsky commented 5 years ago

I am using lando v3.0.0-rc.19 and everything works for me. Docker version 19.03.1, build 74b1e89

kamalkech commented 4 years ago

i guess i understand where the probleme, if i choose proxy with appserver param should not use nginx "via: nginx" must to keep default value as apache2

JPustkuchen commented 3 years ago

Hello internet,

for me the problem was VMWare Workstation "Shared VMs" functionality blocked port 443 on my windows host, so I wasn't able to use .lndo.site subdomains. Docker for Windows with WLS2 integration didn't show an error about the port conflict, I finally found it in the Docker logs.

The same might happen for other programs on port :80 or :443 so these links may help:

Cheers :)

fabianfiorotto commented 2 years ago

I had the same problem with the pantheon recipe. I listed the sub-domains in the edge service

proxy:
  edge:
    - my-site.lndo.site
    - sub.my-site.lndo.site