Configure Apache SSL and then redirect to Tomcat with mod_jk

后端 未结 2 1167
生来不讨喜
生来不讨喜 2021-02-10 06:31

I\'m trying to configure my home server to accept SSL Connection on port 443.

I\'ve www.mydomain.com domain, I\'ve just linked Apache2 and Tomcat, using mod_jk, now I wi

2条回答
  •  终归单人心
    2021-02-10 06:51

    I found the solution, so my Apache and Tomcat work fine... I' going to summarize the steps to solve the problem:

    Considering, you have mydomain certificate (signed by GoDaddy) correctly installed and stored within Apple KeyChain of my Mac Server.

    1. Open KeyChain App (with root), expand mydomain certificate label, so you see the private key too.
    2. Save both with p12 extension, then generate .pem file from .p12
    3. Private Key:

      umask 0077
        openssl pkcs12 -in pkfilename.p12 -nocerts -nodes -out filename-key.pem
      umask 0022
      
    4. Certificate:

      openssl pkcs12 -in certfilename.p12 -clcerts -nokeys -out filename-cert.pem
      
    5. Copy filename-key.pem and filename-cert.pem within /etc/apache2/ directory

    6. Considering you have the same httpd.conf configuration showed above, you just need to add 2 more VirtualHost for 443 (https port) connection.
    7. Anyway, add 1 VirtualHost for each ServerName you wish to secure, for instance I just want to secure mydomain.com incoming connection:

      
          DocumentRoot "/Library/ApacheTomcat/apache-tomcat-6.0.33/webapps/MyServerAppName"
          ServerName mydomain.com
          ErrorLog "/private/var/log/apache2/https_mydomain.com-error_log"
          CustomLog "/private/var/log/apache2/https_mydomain.com-access_log" common
          SSLEngine On
          SSLCertificateFile /etc/apache2/filename-cert.pem
          SSLCertificateKeyFile /etc/apache2/filename-key.pem
          JkMountCopy On
          JkMount /* ajp13
      
      
    8. Add Listen 443 in httpd.conf file, just add this line under Listen 80 you find at beginning of it.

    You now can surf both http:// mydomain.com and https:// mydomain.com. In case of error you can read the log files within /var/log/apache2/.

    Special thanks to Bruno user, how help me on creating privatekey and certificate file (step 3 and 4).

    I hope this guideline can help you configuring Apache and Tomcat on mod_jk for Secure SSL connections.

提交回复
热议问题