-1

I have a docker container with apache and configured my .conf file with a virtual hosts, calling from the client test.dev the virtual host docker is not mapped. If I call localhost it works correctly.

Thanks!!

<VirtualHost *:80>
    Servername test.dev
    SetEnv APPLICATION_ENV "development"
    DocumentRoot "/var/www/html/test/public"
    <Directory "/var/www/html/test/public">
             DirectoryIndex index.php
             AllowOverride All
             Require all granted
    </Directory>
</VirtualHost>
user91404
  • 1
  • 1

1 Answers1

-1

Hostnames can't be "mapped" to a docker container. If you really want to access it locally with a hostname you might want to inject the Host header to every requests or use your hostfile.

Inject the Host header

Whenever I want to test something quickly what I usually do is use curl. If you bind the container to port 8080 on your host:

curl -XGET -H "Host: test.dev" http://localhost:8080

Configure the hostfile

You will have to add 127.0.0.1 test.dev to the hostfile. The path is relative to your OS:

  • On Windows: c:\windows\system32\drivers\etc\hosts
  • On Unix: /etc/hosts

Once this is done, you can open the browser and head to http://test.dev:8080

0x9BD0
  • 1,542
  • 18
  • 41