[아파치] 80포트로 접속시 특정 서브 도메인 제외하고 모두 차단하는 방법

2023. 8. 14. 15:12개발 참고

반응형

/etc/httpd/conf/httpd.conf

<VirtualHost *:80>
    ServerName example.com
    
    # http로 리다이렉트할 경우 프로그램 처리시 문제될수가 있음
    # 서버에 request로 호스트가져올 경우 도메인을 가져오는게 아닌 localhost로 가져옴
    # ProxyPass / http://localhost:8081/
    # ProxyPassReverse / http://localhost:8081/
    
    ProxyPass / ajp://localhost:8009/
    ProxyPassReverse / ajp://localhost:8009/

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^admin\.example\.com$ [NC]
    RewriteCond %{HTTP_HOST} !^admin\.example\.co\.kr$ [NC]
    RewriteRule ^ - [F]
</VirtualHost>

<VirtualHost *:80>
    ServerName example.co.kr
    
    # http로 리다이렉트할 경우 프로그램 처리시 문제될수가 있음
    # 서버에 request로 호스트가져올 경우 도메인을 가져오는게 아닌 localhost로 가져옴
    # ProxyPass / http://localhost:8081/
    # ProxyPassReverse / http://localhost:8081/
    
    ProxyPass / ajp://localhost:8009/
    ProxyPassReverse / ajp://localhost:8009/
    
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^admin\.example\.com$ [NC]
    RewriteCond %{HTTP_HOST} !^admin\.example\.co\.kr$ [NC]
    RewriteRule ^ - [F]
</VirtualHost>

 

반응형