One site, multiple domain

If i want to use 2 domains on the same container/site, does Local support this?
I have created a site, a WP Multisite that runs on 2 different domains. (Not on sub-directories or sub-domains). and How can one achieve this when using Local?

Really good job with the new update btw, looking smashing!

Hi @robsat91,

There isn’t an option for this at the moment but it’s on our radar!

I know @benjamin was able to come up with a workaround in the meantime :slight_smile:

Did you ever figure this out? I’m looking to do this now (actually with different subdomains, but assuming it’s the same setup). @benjamin - mind sharing your work around?

@justinkorn I also used it for subdomains, but am not using it at the moment. I’ll try to get some steps on exactly what I did over the next few days and let you know.

@justinkorn, here are the steps to how I got it to work.

Easy stuff:

  1. Open ~/Library/Application Support/Local by Flywheel/routes/{site}.conf in your favorite editor.
  2. Add the new domain to the server_name variable. Such as: server_name * *;. Save that file.
  3. Navigate to your site directory and open the ../../conf/nginx/site.conf file in your favorite editor.
  4. Inside the second server block, modify the server_name variable so it looks like: server_name ~^(.*)\.site1\.dev$ ~^(.*)\.site2\.dev$;. Save that file.
  5. The new domain needs to also be manually added to your hosts file. You can do this by editing the hosts file: sudo nano /etc/hosts. Then locate the Flywheel section (usually at the bottom) and add in the site using the same domain:

Hard stuff:

  1. Open up the terminal and navigate to: /Applications/Local\ by\
  2. Set the environment: eval $(./docker-machine env local-by-flywheel)
  3. List out the current containers: ./docker ps
  4. Find the container that is routing port 80 to port 80 and copy the CONTAINER ID or the NAME. For example:
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                                         NAMES
af902257ae16        flywheel:latest     "nginx -g 'daemon ..."   11 minutes ago      Up 11 minutes>80/tcp,>443/tcp                                                      romantic_volhard
0a6811dc0617        c14d8b5229eb        "/etc/scripts/slee..."   2 months ago        Up 2 days >80/tcp,>443/tcp,>1080/tcp,>3306/tcp   peaceful_keller
d93c18b6d674        abcd58700580        "/etc/scripts/slee..."   3 months ago        Up 2 days >80/tcp,>443/tcp,>1080/tcp,>3306/tcp   keen_cori
f363201da868        3c796fcbeea7        "/etc/scripts/slee..."   7 months ago        Up 11 minutes>80/tcp,>443/tcp,>1080/tcp,>3306/tcp   hopeful_pasteur
ced2e08aff5e        4097c04a54d5        "/etc/scripts/slee..."   9 months ago        Up 2 days >80/tcp,>443/tcp,>1080/tcp,>3306/tcp   amazing_babbage

In this example, the first entry is routing from port 80 to port 80 and the CONTAINER ID is af902257ae16 and the NAME is romantic_volhard.

  1. SSH into the container using the CONTAINER ID or NAME: ./docker exec -it {CONTAINER ID|NAME} /bin/bash
  2. Look up the process for nginx with ps aux. It will spit out a list similar to:
root         1  0.0  0.5  33144  5884 ?        Ss+  02:01   0:00 nginx: master process nginx -g daemon off; -c /etc/nginx-router/router.conf
www-data     5  0.0  0.3  33144  3440 ?        S+   02:01   0:00 nginx: worker process
root         6  0.0  0.3  20248  3208 ?        Ss   02:16   0:00 /bin/bash
root        10  0.0  0.2  17504  2052 ?        R+   02:17   0:00 ps aux
  1. Using the router.conf path, reset nginx: nginx -c /etc/nginx-router/router.conf -s reload

That’s it! you should now be able to navigate in your browser to your new domain name to see if it points you to the correct site:

Let me know if you have any questions!

1 Like

Wow! Thank you for all the details, Ben. Seems like a lot of work for such a minor thing, but I’ll try to follow the directions and see where I get with them. Thanks again for sharing!

1 Like

I ran into the same issue where I want multiple domains pointing to one instance. I found the instructions in “Local Router Error” message on multi-network instance to be much simpler. It’s just a matter of copying a conf file.

FWIW, the path in Hard Stuff, step 1 is now:
/Applications/Local by

I managed to get this work with these modifications:

Skipped easy part 3 and 4.

cd /Applications/Local by

If this line does not work:
./docker exec -it {CONTAINER ID|NAME} /bin/bash
try this:
./docker exec -it {CONTAINER ID|NAME} /bin/sh

And if this does not work
nginx -c /etc/nginx-router/router.conf -s reload
use this
nginx -c /etc/nginx/nginx.conf -s reload