dnsmasq を使って GitLab Pages のサブドメインを動的に処理します。
/etc/hosts で各サイトを設定しなくても、dnsmasq を使って GitLab Pages のサイトを内部でテストすることができます。
MacOS でdnsmasq を使う
MacOSでdnsmasq :
-
dnsmasqをインストールします:
brew install dnsmasq
-
*.testドメイン検索を設定します:
# Ensure the configuration directory exists
mkdir -p $(brew --prefix)/etc/
# Add `*.test` to the `127.0.0.1` lookup
echo 'address=/.test/127.0.0.1' >> $(brew --prefix)/etc/dnsmasq.conf
# Start `dnsmasq`
sudo brew services start dnsmasq
- DNSリゾルバを作成します:
# Ensure the resolver directory exists
sudo mkdir -p /etc/resolver
# Add the localhost address as a resolver for `.test` domains
echo "nameserver 127.0.0.1" | sudo tee /etc/resolver/test
GitLab Pages サイトをローカルに動的ドメインで作成できるようになりました。GitLab Pagesを設定してroot/html プロジェクトを作成すると、そのプロジェクトはhttp://root.gdk.pages.test:3010/htmlからアクセスできるようになります。
トラブルシューティング
GitLab Runnerでは、gdk.test を/etc/hosts. /etc/hostsNETで設定する必要があります/etc/hosts。 GitLab Runnerをローカルで使用している場合は、.NETも設定する必要があります /etc/hosts:
# Append GDK configuration in `/etc/hosts`
cat <<-EOF | sudo tee -a /etc/hosts
## GDK
127.0.0.1 gdk.test
::1 gdk.test
# ----------------------------
EOF