
Apache2.4와tomcat8.5를Windows Failover Cluster에 역할 등록한 상황입니다.
- 외부IP :
192.168.0.x- 내부IP :
10.10.0.x
Client가 접속할 수 있는 IP는 외부IP이고, 내부IP로 Apache2.4 와 Tomcat8.5를 통신하게 구성했습니다.
Apache24를 설명하기 전,Tomcat8.5설정을 먼저 확인해보겠습니다.
Tomcat8.5 역할 Cluster VIP : 10.10.0.110Tomcat8.5의 포트 8080따라서, 10.10.0.110:8080 으로 접속되게 하면된다.
Cluster VIP(Virtual IP)는Node1과Node2를Active/standby로failover되면 왔다갔다할IP입니다.
Tomcat의conf/server.xml수정
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8888" />
<Engine name="Catalina" defaultHost="10.10.0.110">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="10.10.0.110" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
Client가외부IP로 앞단에Apache 24를 통해서 접속하고,Proxy로내부IP로Tomcat8.5에 넘겨주도록 설계했습니다.
- 추가로
SSL설정을 해주어, 기본 접속 포트는443입니다.- 예시로,
192.168.0.85의 DNS는 helloworld.test.com이며,SSL 인증서는*.test.com으로 하겠습니다.
Client -> https://helloworld.test.comApache24에서 *:443 접속주소 수신Apache24에서 tomcat8.5 ip주소인 http://10.10.0.110:8080로 proxy
apache의conf/httpd.conf수정
Apache가 수신하는 포트들
Listen 443
Listen 5000
Listen 5001
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule ssl_module modules/mod_ssl.so
httpd.conf맨 아래에 추가
<VirtualHost helloworld.test.com:443>로ServerName을 명시하지 않고,<VirtualHost *:443>로 설정해도 무방합니다.- 모든 접속 주소(
/)를 (/http://10.10.0.110:8080/)로 proxy 하며, 맨 뒤의/를꼭!붙여야합니다.
<VirtualHost helloworld.test.com:443>
ServerName helloworld.test.com
ProxyRequests Off
ProxyPass / http://10.10.0.110:8080/
ProxyPassReverse / http://10.10.4.110:8080/
<Proxy *>
Require all granted
</Proxy>
# SSL 인증서 파일 경로 설정
SSLEngine on
SSLCertificateFile "C:/Apache24/ssl/cert.pem"
SSLCertificateKeyFile "C:/Apache24/ssl/newkey.pem"
SSLCACertificateFile "C:/Apache24/ssl/DigiCertCA.pem"
</VirtualHost>
Apache24에서WSGI로flask서버를 실행시키기 위한 세팅입니다.
Listen포트는5000,5001
<VirtualHost helloworld.test.com:5000>
ServerName helloworld.test.com
WSGIScriptAlias / "C:/rest/flask_first.wsgi"
<Directory C:/rest>
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
# SSL 인증서 파일 경로 설정
SSLEngine on
SSLCertificateFile "C:/Apache24/ssl/cert.pem"
SSLCertificateKeyFile "C:/Apache24/ssl/newkey.pem"
SSLCACertificateFile "C:/Apache24/ssl/DigiCertCA.pem"
</VirtualHost>
<VirtualHost helloworld.test.com:5001>
ServerName helloworld.test.com
WSGIScriptAlias / "C:/rest/flask_second.wsgi"
<Directory C:/rest>
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
# SSL 인증서 파일 경로 설정
SSLEngine on
SSLCertificateFile "C:/Apache24/ssl/cert.pem"
SSLCertificateKeyFile "C:/Apache24/ssl/newkey.pem"
SSLCACertificateFile "C:/Apache24/ssl/DigiCertCA.pem"
</VirtualHost>
Apache SSL인증서 관련 내용
인증서에 Chain 인증서가 없는 경우, SSLCACertificateFile를 제외하고 파일 경로 설정하면된다.
인증서의 확장자가 꼭 pem일 필요는 없다.
SSLCertificateFile "C:/Apache24/ssl/cert.crt"
SSLCertificateKeyFile "C:/Apache24/ssl/newkey.key"
SSLPassPhraseDialog exec:C:/Apache24/conf/pass.bat
# pass.bat
@echo password
위 내용은 WSGI 포트 접속 관련된 내용만 있습니다. WSGI 세팅은 LoadModule wsgi_module, WSGIPythonPath 등이 필요할 수 있습니다.
감사합니다.