Programming > Docker

Tomcat에 SSL (https)적용하기

Tomcat에 SSL (https)적용하기 (basic)

도커 컨테이너를 기동해 자가인증 SSL적용하기 (도커)

docker run -it -p 18080:18080 -p 28080:28080 -p 18443:18443 -p 28443:28443 --name tomhttps centos:7

yum -y install java
mkdir -p /emc/soft
cd /emc/soft
curl -L -O https://downloads.apache.org/tomcat/tomcat-8/v8.5.58/bin/apache-tomcat-8.5.58.tar.gz
tar zxf apache-tomcat-8.5.58.tar.gz
cp -r apache-tomcat-8.5.58 tom1
cp -r apache-tomcat-8.5.58 tom2

자가인증키생성

keytool -genkey -alias tomcat -keypass 999999 -storepass 999999 -keyalg RSA -keystore /emc/soft/.keystore -dname "CN=localhost, OU=OrgUnit, O=MyCompany, C=KR"

설정파일 수정하기

vi tom1/conf/server.xml

    <Connector port="18080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="18443" />

## Windows 에서 아래 사용 (대소문자 유의)
    <Connector port="18443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" 
               keystorePass="999999" keystoreFile="/emc/soft/.keystore" />

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="21809" protocol="AJP/1.3" redirectPort="18443"/>


    <Connector port="18443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true">
        <SSLHostConfig>
            <Certificate certificateKeystoreFile="/emc/soft/.keystore"
                         certificateKeystorePassword="999999"
                         type="RSA" />
        </SSLHostConfig>
    </Connector>


https://192.168.99.100:18443