Docker4drupal: How to map localhost:port to domain name

Created on 23 Sep 2016  路  7Comments  路  Source: wodby/docker4drupal

21 and https://github.com/Wodby/docker4drupal/blob/master/README.md recommend using different port numbers for different sites.

That works, but if you work with 3 or more sites it starts to get confusing.

Is there a quick way to assign domain names instead of localhost:port via docker-compose.yml?
Perhaps by using a local IP address which then can be mapped via the hosts file.

help wanted

Most helpful comment

You can now use docker4drupal with domains https://docs.wodby.com/stacks/drupal/local/#domains

All 7 comments

...
PHP_SITENAME: mysite.com
...
NGINX_SERVER_NAME mysite.com
...
then add to your hosts
127.0.0.1 mysite.com
But you still have to use port forvarding and access site by mysite.com:8000 because 80 ports is already taken by another process (by docker, as I understand).
And use PHP_SITENAME because there is typo in source files for the corresponding image.

And use PHP_SITENAME because there is typo in source files for the corresponding image.

By the way, this issue has been fixed in #43.

Can't we have one more nginx container that will act as a proxy in a separate project.

In the proxy configs, you will bind the domain:port mappings, using base ports ranges for name-spacing.
Proxy will work on port 80 and 443 (for SSL).
Like so:
Project 1 -> 7XXX ports, project 2 -> 8XXX and so on.

In the proxy you have:
mysyte1.local goes to localhost:7XXX
mysyte2.local goes to localhost:8XXX
.. And so on.

When starting new project:

  1. Only once - add definition in your local proxy configuration and hosts file
    ( this will be a centralized thing to be actively used for all projects)
  2. You prepare everything (with custom ports in your composer file)
  3. Have fun :)

@ndobromirov's idea sounds good.

If this is implemented it would make it possible to run sites utilizing the Domain Access module (https://www.drupal.org/project/domain) locally (we need it for our most important site).

Also, it would also be a solution for #21.

I am currently using jwilder/nginx-proxy container to get name resolving but Pavel has already said something about using containous/traefik in #50

@macmladen can you elaborate on how you are using nginx-proxy a bit (e.g. give some sample configs) ... I've been trying to get this working for a bit without success. This workaround seems promising but having some examples would be great!!

You can now use docker4drupal with domains https://docs.wodby.com/stacks/drupal/local/#domains

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jzavrl picture jzavrl  路  3Comments

LordFransie picture LordFransie  路  3Comments

quietone1 picture quietone1  路  10Comments

jayjaydluffy picture jayjaydluffy  路  5Comments

quietone1 picture quietone1  路  10Comments