가령, http://abc.airpage.org 로 접근할 경우 도메인 주소의 변경 없이 http://airpage.org:8080 으로 접속하도록 설정하는 방법입니다.
Centos 7 환경에서 작업한 내용입니다.
1. 도메인 서비스 업체의 도메인 관리 서비스에서 CNAME 설정을 하나 추가합니다. 즉, 'blog.airpage.org'와 같은 서브 도메인을 만들려면 아래처럼 생성합니다.
CNAME blog @
2. 'blog' 서브 도메인을 위한 가상 호스트 설정을 생성합니다.
$ sudo vi /etc/httpd/sites-available/blog.airpage.org.conf $ sudo ln -s /etc/httpd/sites-available/blog.airpage.org.conf /etc/httpd/sites-enabled/blog.airpage.org.conf
3. 'blog.airpage.org.conf' 파일의 내용을 아래와 같이 작성합니다.
<VirtualHost *:80>
ServerAdmin admin@airpage.org
ServerName blog.airpage.org
ServerAlias blog.airpage.org
ProxyRequests Off
<Location />
ProxyPreserveHost On
ProxyPass http://airpage.org:8080/
ProxyPassReverse http://airpage.org:8080/
</Location>
#만약 https 를 사용할 경우 아래 주석을 풀어줍니다.
#SSLProxyEngine On
</VirtualHost>4. apache 서버를 재시동 시킵니다.
$ sudo apachectl restart
건투를 빕니다!
[참조경로]
- https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7
- https://serverfault.com/questions/195611/how-do-i-redirect-subdomains-to-a-different-port-on-the-same-server