[Tomcat] HTTPS 설정 하기 (AprProtocol)
Tomcat 에서 https 로 접속하도록 하는 설정
- Server Key 생성
- Apr 설치
- tomcat-native library 설치
- 톰캣 실행 파일(startup.sh) 에 native library가 설치 된 지정
- server.xml 설정
- web.xml 설정
1. Serverkey 생성
- openssl genrsa -des3 -passout pass:your_password -out server.key 1024
- openssl req -new -passin pass:your_password -key server.key -passout pass:your_password -out server.csr
- openssl x509 -req -days 1095 -in server.csr -passin pass:your_password -signkey server.key -out server.crt
2. Apr 컴파일
3. Tomcat native library 컴파일
4. 톰캣 실행 파일(startup.sh)에 Tomcat native library 경로 지정
- export LD_LIBRARY_PATH=/usr/local/apache-tomcat/lib
5. server.xml 설정
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" SSLRandomSeed="builtin"/>
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Service name="Catalina">
<Connector protocol="org.apache.coyote.http11.Http11AprProtocol"
port="443" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
SSLCertificateFile="/path_to/server.crt"
SSLCertificateKeyFile="/path_to/server.key"
SSLPassword="your key password"
SSLProtocol="TLSv1"
SSLCipherSuite="ALL:!SSLv2:!aNULL:!ADH:!kEDH:!eNULL:!NULL:!LOW:!MEDIUM:!EXP:RC4+RSA:+HIGH"/> <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
<Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" SSLRandomSeed="builtin"/>
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Service name="Catalina">
<Connector protocol="org.apache.coyote.http11.Http11AprProtocol"
port="443" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
SSLCertificateFile="/path_to/server.crt"
SSLCertificateKeyFile="/path_to/server.key"
SSLPassword="your key password"
SSLProtocol="TLSv1"
SSLCipherSuite="ALL:!SSLv2:!aNULL:!ADH:!kEDH:!eNULL:!NULL:!LOW:!MEDIUM:!EXP:RC4+RSA:+HIGH"/> <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
</Server>
6.web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>Restrict URLs</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>PUT</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<!-- HTTP 사용하고픈 URL 표시 -->
<security-constraint>
<web-resource-collection>
<web-resource-name>Exclude URLs</web-resource-name>
<url-pattern>/can/use/http</url-pattern>
</web-resource-collection>
</web-resource-collection>
</security-constraint>
댓글
댓글 쓰기