ssltomcathttpsserver.xml

Tomcat is not starting in port 8443


I have hosted a website using apache server in a ubuntu VM in digitalocean. I want to configure SSL on Tomcat 8 on my backend url to make it HTTPS.

For that, I generated a .keystore and changed the server.xml file in the tomcat/config directory. But when I loaded port 8443 along with my ip ( https://111.11.11.11:8443/ )it doesn't load. The port 8443 is not in the listening list in the server.

My server.xml file is as follws.

<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
          type="org.apache.catalina.UserDatabase"
          description="User database that can be updated and saved"
          factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>


<Service name="Catalina">


<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />


<Connector SSLEnabled="true" acceptCount="100" clientAuth="false"
       disableUploadTimeout="true" enableLookups="false"
       keystoreFile="/home/sedsslweb/tomcat.keystore" keystorePass="password"
       maxThreads="25" port="8443"
       protocol="org.apache.coyote.http11.Http11NioProtocol"
       scheme="https" secure="true" sslProtocol="TLS"/>

 <Engine name="Catalina" defaultHost="localhost">

 <Realm className="org.apache.catalina.realm.LockOutRealm">
 <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
           resourceName="UserDatabase"/>
 </Realm>

 <Host name="localhost"  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 &quot;%r&quot; %s %b" />

  </Host>
</Engine>
</Service>
</Server>

Bacically what I want is to make the backend url https beacuse I can't send request from my https frontend url to bacekend http url beacause it is blocked because of the mixed content (Both frontend and backened must be whether https ot http).

I'm stuck in this issue for days and can anyone please help me to solve this isssue. Or atleast a alternative to make backend https.

Ps: In catalina.out I got this error.

 org.apache.catalina.LifecycleException: Protocol handler initialization failed
            at org.apache.catalina.connector.Connector.initInternal(Connector.java:1077)
            at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
            at org.apache.catalina.core.StandardService.initInternal(StandardService.java:557)
            at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
            at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:850)
            at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
            at org.apache.catalina.startup.Catalina.load(Catalina.java:639)
            at org.apache.catalina.startup.Catalina.load(Catalina.java:662)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:305)
            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475)
    Caused by: java.lang.IllegalArgumentException: /opt/tomcat/tomcat.keystore (Permission denied)
            at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:100)
            at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:72)
            at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:247)
            at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1147)
            at org.apache.tomcat.util.net.AbstractJsseEndpoint.init(AbstractJsseEndpoint.java:222)
            at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:599)
            at org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:80)
            at org.apache.catalina.connector.Connector.initInternal(Connector.java:1074)

Solution

  • I just changed the permission of the /opt/tomcat directory and it works like a charm.

    chown -R tomcat:tomcat /opt/tomcat