4

We are using docker4drupal with our sites for local development. The problem is that the sites only work in Chrome. Another user had the same issue here.

Here is output of cat /etc/hosts inside my container:

127.0.0.1   localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.20.0.5  d012518e289d
6
  • can you show what's the result of cat /etc/hosts on your container?
    – Edwin
    Aug 23, 2017 at 11:57
  • Updated the issue with the output.
    – albertski
    Aug 23, 2017 at 12:10
  • try to change 172.20.0.5 d012518e289d to 172.20.0.5 *.docker.localhost and run again
    – Edwin
    Aug 23, 2017 at 12:16
  • It didn't work after the update. If I restart the container it goes back to 172.20.0.5 d012518e289d.
    – albertski
    Aug 23, 2017 at 12:38
  • but does it work if you go to localhost:PORT in any browser?
    – Edwin
    Aug 23, 2017 at 13:00

3 Answers 3

3

I was able to solve this by adding this to my host file:

127.0.0.1 mysite.docker.localhost
1
  • 2
    Doesn't this kind of defeat the point of using Traefik in the first place? It's supposed to do this automatically for you. Apr 17, 2018 at 15:00
0

As for browser support, the .localhost TLD resolution to 127.0.0.1 works in Firefox as well for me (I test Firefox 56).

Judging from the other comments, I think some people might be running into some kind of server side redirection perhaps because the Host header is not passed. Be sure to have Traefik pass the Host header to the backends. It does this by default though but you can verify it per frontend on the Traefik dashboard page.

To set it explicitly, add the following label to the relevant Docker container in your docker-compose.yml file:

labels:
  traefik.frontend.passHostHeader: 'true'

For instance, if I set this to 'false' for the Solr container, then the Solr server redirects me to it's container IP instead of serving on the 'nice' domain name.

0

Once I started using .test instead of .localhost I didn't run into this issue and I didn't have to update my host file.

1
  • Didn't help me at all
    – holms
    Sep 3, 2018 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.