0

I am working on loadbalancing 2 servers. Both of them are on different domain names. I have configured load balancing for them according. Currently, I am getting failed to make connection. What am I doing wrong? Also, what configuration do I need to make on server2 for this to work?

Error log :

Connection refused: AH00957: HTTP: attempt to connect to IP:8090 (IP) failed

Apache 000-default.conf :

<VirtualHost *:443>
ServerName domain.de
ServerAlias www.domain.de
SSLEngine on
SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
SSLCertificateFile /etc/letsencrypt/live/domain.de/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.de/private.key
SSLCertificateChainFile /etc/letsencrypt/live/domain.de/chain.pem
<Proxy balancer://mycluster>
       BalancerMember http://IP:8090 route=server1
       BalancerMember http://IP:8009 route=server2
</Proxy>
 ProxyPass /balancer-manager !
 ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://cluster/
ProxyPreserveHost On
</VirtualHost>

Tomcat :

<Connector port="8443" enableLookups="true" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true" 
maxThreads="200" disableUploadTimeout="true" connectionTimeout="36000"
compression="off" sslProtocols="TLS" sslEnabledProtocols="TLSv1.2,TLSv1.1,TLSv1" ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_
ECDHE_RSA_WITH_AES_256_CBC_SHA384,
 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA256,
TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA,SSL_RSA_WITH_RC4_128_SHA"
 compressionMinSize="1024" scheme="https" secure="true" clientAuth="false" 
keystoreFile="/etc/letsencrypt/live/domain.de/KEYSTORE.jks" keyPass="PASS" keyAlias="tomcat" keystorePass="PASS" URIEncoding="utf-8"/>

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <Engine name="Catalina" defaultHost="localhost" jvmRoute="server1">
4
  • ProxyPassReverse / balancer://cluster/ should be ProxyPassReverse / balancer://mycluster/ Feb 25, 2019 at 10:28
  • @RomeoNinov : Thanks. Changed that. I am still getting (111)Connection refused: AH00957: HTTP: attempt to connect to server 1 IP. Can you tell me what configuration should I use on Server2? Because this would mean that apache is contacting server 2 on non-standard ports, blocked by default. Feb 25, 2019 at 10:32
  • Disable firewall or open those ports for communication Feb 25, 2019 at 10:34
  • @RomeoNinov : Okay, but it's not working for either of the servers. Any ideas what is wrong with my configuration? Feb 25, 2019 at 10:36

1 Answer 1

1

Your HTTPS connector is running on port 8443 and AJP on 8009, not on 8090.

Edit:

<Proxy balancer://mycluster>
       BalancerMember ajp://SERVER1_IP:8009 route=server1
       BalancerMember ajp://SERVER2_IP:8009 route=server2
</Proxy>
ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/

# I think you can remove these lines
#ProxyPassReverse / balancer://mycluster/
#ProxyPreserveHost On
10
  • I thought proxy-balancer works with jvmRoute, but I tried to change the file 000-default.conf to point at 8443, still no luck, and no error log as well this time. Feb 25, 2019 at 10:45
  • Sorry, I didn't see your AJP connector on 8009. But still, in your Apache config are 8090 (server1) and 8009 (server2) defined. If the posted Tomcat config is from server1, then you have to change the port to 8009 in the Apache config as well and change the protocol to "ajp://".
    – Freddy
    Feb 25, 2019 at 10:56
  • After changing it to 8009 for Server1, I get : [ajp-nio-8009-exec-1] org.apache.coyote.ajp.AjpMessage.processHeader Invalid message received with signature [18245] inside Tomcat. Inside Apache I get : AH00898: Error reading from remote server returned by / Feb 25, 2019 at 11:00
  • Change the protocol to "ajp://" like in Apache Module mod_proxy_ajp
    – Freddy
    Feb 25, 2019 at 11:04
  • Looks like it's gonna work now. I had to a2enmod proxy_ajp. I just have 1 question. Do I need to open ports for AJP on server2 or can I do this virtual host on server2? What's the configuration required on server2? Feb 25, 2019 at 11:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .