dnsmasq
를 사용하여 GitLab Pages 하위 도메인을 동적으로 처리하는 방법
당신은 dnsmasq
를 사용하여 로컬에서 GitLab Pages 사이트를 각 사이트를 /etc/hosts
에 구성하지 않고 테스트할 수 있습니다.
macOS에서 dnsmasq
사용하기
macOS에서 dnsmasq
를 사용하려면:
-
dnsmasq
를 설치하세요:
brew install dnsmasq
-
*.test
도메인 조회를 설정하세요:
# 설정 디렉터리가 존재하는지 확인하세요
mkdir -p $(brew --prefix)/etc/
# `*.test`를 `127.0.0.1` 조회에 추가하세요
echo 'address=/.test/127.0.0.1' >> $(brew --prefix)/etc/dnsmasq.conf
# `dnsmasq`를 시작하세요
sudo brew services start dnsmasq
- DNS 리졸버를 생성하세요:
# 리졸버 디렉터리가 존재하는지 확인하세요
sudo mkdir -p /etc/resolver
# localhost 주소를 `.test` 도메인의 리졸버로 추가하세요
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의 경우, /etc/hosts
에서 gdk.test
를 정의해야 합니다.
로컬에서 GitLab Runner를 사용하는 경우, /etc/hosts
도 구성해야 합니다:
# `/etc/hosts`에 GDK 구성 추가
cat <<-EOF | sudo tee -a /etc/hosts
## GDK
127.0.0.1 gdk.test
::1 gdk.test
# ----------------------------
EOF