Search code examples
apachetomcatmod-proxysap-commerce-cloud

Forwarding two web servers https and http requests to single hybris tomcat server


We have two apache 2.4.6 web servers and one hybris tomcat 7 server in same network, I need to configure the webservers with mod_proxy to forward http and https requests to hybris server and the webservers have different domain names. My question is how to configure tomcat to accept requests from two different domain names and is the proxyName parameter is sufficient. Below are the my basic mod_proxy configuration.

 LoadModule headers_module modules/mod_headers.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule ssl_module  modules/mod_ssl.so

<VirtualHost *:80>
DocumentRoot /var/www/html
ProxyPreserveHost On
ProxyPass / http://tomcatserver.ip:9001/
ProxyPassReverse /  http://tomcatserver.ip:9001/
</VirtualHost>

<VirtualHost *:443>
  DocumentRoot /var/www/html
   ProxyPreserveHost On
   ServerName webserver.ip
    SSLEngine on
    SSLProxyEngine On
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerExpire off
    ProxyPass / https://tomcatserver.ip:9002/
    ProxyPassReverse /  https://tomcatserver.ip:9002

     SSLCertificateFile /etc/ssl/certs/webserverdomain.crt
     SSLCertificateKeyFile  /etc/ssl/certs/webserverdomain.key    
     </VirtualHost>

server.xml configuration

<Connector port="${tomcat.http.port}" maxHttpHeaderSize="8192" maxThreads="${tomcat.maxthreads}" protocol="org.apache.coyote.http11.Http11Protocol" executor="hybrisExecutor" enableLookups="false" acceptCount="100" connectionTimeout="20000" URIEncoding="UTF-8" disableUploadTimeout="true" proxyName="webserverdomainname" proxyPort="80" /> /> <Connector port="${tomcat.ssl.port}" maxHttpHeaderSize="8192" maxThreads="150" protocol="org.apache.coyote.http11.Http11Protocol" executor="hybrisExecutor" enableLookups="false" acceptCount="${tomcat.acceptcount}" connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8" SSLEnabled="true" proxyName="webserverdomainname" proxyPort="443" scheme="https" secure="true" clientAuth="false" sslProtocol = "TLS" keystoreFile="${catalina.home}/lib/keystore" keystorePass="123456"enter code here

Solution

  • If I understand correctly you have 2 Apache web servers with 2 different domain names that you'd like to connect to the same Hybris Tomcat.

    If this is correct then the only thing you need to configure is to configure the Hybris website url mapping to catch all required domain name.

    Also about the proxy name, From Tomcat 7 documentation :

    Proxy name : If this Connector is being used in a proxy configuration, configure this attribute to specify the server name to be returned for calls to request.getServerName(). See Proxy Support for more information.

    If you had to configure Tomcat to match different domain name with different Hosts have a look at the host container.