This is applicable for MacOS. I'm using MacOS BigSur 11.2.3. Linux family should be similar
You'll need to do 2 things:
- Edit the HOST file in your computer to let it know about your custom domain
- Setup a server to do port-forwarding (skip this step if you don't need port-forwarding)
Note: Replace {{YOUR_DOMAIN}}
with your domain.
- Edit the HOST file
- Either run commands such as
sudo nano /etc/hosts
orsudo code /etc/hosts
if you use VSCode, to edit the file manually. - Or a more simple command:
echo "127.0.0.1 {{YOUR_DOMAIN}}" | sudo tee -a /etc/hosts
(I couldn't useecho
directly - Permission denied).
- Setup a server
- You need to have Docker installed.
- Copy 3 files (docker-compose.yaml, Dockerfile, nginx.conf) into a folder.
- In nginx.conf, replace
{{YOUR_PORT}}
with your port. - Run
docker-compose build && docker-compose up
.
Inspired by: https://emmapopoola.medium.com/setting-up-a-custom-domain-for-your-local-apps-mac-os-linux-c68798722143