apache + tomcat using mod_proxy ajp randomly stops working - apache

I am using apache and mod_proxy (via ajp) to send traffic to my tomcat instance. Everything works fine and then it randomly breaks. I see a 408 in the tomcat logs and apache is returning a 503.
Has anyone seen this before? Any reason this would occur?

Do you have a firewall between Apache and Tomcat? I've had problems in the past while setting up AJP when a firewall was present. If it is your problem, take a look:
http://tomcat.apache.org/connectors-doc/generic_howto/timeouts.html

This ended up being due to the way amazon's load balancer does health checks. I ended up switching to mod_jk and using a random port for the health check to occur where normal traffic does not occur.

Related

HAProxy check backend on 2 ports

we have apache in front of tomcat. it happens that the tomcat crashes and the apache still serve the webpage with a 503 page.
there's a way, via HAProxy to check both ports: 80 and 8080 and then bring the node up?
I added the http-check expect rstatus (2|3)[0-9][0-9] and the http-check expect ! rstatus ^5 but none of the 2 detected that tomcat was unreachable while the apache was providing the service.
thank you a lot
Nick
If your health check is configured correctly, you don't have to test both ports -- just configure the health check to send a request to apache that will be served by tomcat, using option httpchk. A 503 response will cause cause that server to be declared unhealthy.
the problem was the / at the end that did a redirect. once modified, works correctly with the expect 200.

HTTP Load Balancing - rdirect only if first worker fails using mod_jk

I have used Apache HTTPD mod_jk and Tomcat for a high availability solution. Here is the workers.properties for it.
worker.list=myworker
worker.myworker1.port=8009
worker.myworker1.host=host1
worker.myworker1.type=ajp13
worker.myworker1.lbfactor=1
worker.myworker2.port=8009
worker.myworker2.host=host2
worker.myworker2.type=ajp13
worker.myworker2.lbfactor=1
worker.myworker.type=lb
worker.myworker.balance_workers=myworker1,myworker2
worker.myworker.sticky_session=True
Right now, the requests are equally distributed among the workers and applications are working fine. What I want is, all the requests must go to myworker1. Only if myworker1 is down, it should be redirected to myworker2.
Is there a way possible with mod_jk for this?
Redirect to myworker2 in case myworker1 fails
Disable myworker2 for all the requests except for failover
These two lines must be added to your file
worker.myworker1.redirect=myworker2
worker.myworker2.activation=disabled
See:
https://salonegupta.wordpress.com/2014/08/27/apache-load-balancer-setup-with-failover-mechanism/ for more information

Configure Varnish with SSL for Drupal 7 application

I have 2 servers, one running my Drupal 7 application through Apache on RHEL 6 and another server is running Varnish Cache. Apache is configured to run on custom HTTP port 8080. I want this application to run on 9443 port with SSL with Varnish Caching support.
I have tried Stunnel, but the site appears broken as the css are not being loaded. I have tried Nginx for SSL termination but browsers complain that there are mixed content as Drupal is generating URLs for resources with "http://".
Any help regarding this will be highly appreciated. Thanks a lot.
You problem is that according to drupal you are running http, and therefore will also return http links. which causes your mixed content issue. have you set your base_url to https?

Apache Server - Change port from 8080 to 80

I have recently bought Amazon EC2 server.
Instead of installing it trough command line, I downloaded the latest zip file and deployed my application in WebApps folder.
The problem is tomcat is listening all the requests on port 8080 instead of 80.
I have tried changing the server.xml file in conf folder but no help!!
It is still listening to port 8080.
How do I make it listen to port 80
Oddly enough, Tomcat has its own documentation about doing this:
http://wiki.apache.org/tomcat/HowTo#How_to_run_Tomcat_without_root_privileges.3F
Probably the most straightforward way on *NIX is to use jsvc which is a small utility that works by binding to a port, dropping privileges, and then launching Tomcat, which can then use lower-numbered ports.
There are a bunch of other ways, but jsvc is the easiest and offers some other benefits as well. Discovering those benefits is left as an exercise for the reader.
The following would apply toward various systems, while the second link would related toward windows based systems.
First link :http://www.klawitter.de/tomcat80.html
Second link:
http://javarevisited.blogspot.com/2011/12/how-to-change-tomcat-default-port-8080.html?m=1
Ok. So finally I figured out way to solve this problem.
First of all i was doing it wrong way. One should not open port 80 for tomcat7. Tomcat7 should always run port 8080 or anything which is greater than 1024.
So to make your web site work without port. Follow below steps.
Install Apache2. (By default it runs on port 80).
Go to localhost and make sure apache2 is installed properly.
Then you will have to redirect all the requests which are going on port to redirect to port 8080.
To do that follow below link. (this is important step)
https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension
Hope this answer helps!!!
Thanks
Fahad Mullaji
I wouldn't recommend doing that, for what it is worth...
That could work in theory, but you are literally using httpd as a proxy to forward every request. There isn't much of a reason, IMHO, to choose this over simply changing the port to 80 in the Tomcat configuration and ditching httpd. You can use port 80 for Tomcat but historically, in production environments, httpd is generally used to serve static assets and such and dynamic content would be served by Tomcat. Generally one would install mod_jk and use the jkMount directive to connect Tomcat to httpd via AJP, which is a lot faster being a binary protocol than using HTTP.
There used to be a much bigger difference in terms of performance, here.
Tomcat is able to serve static resources via its DefaultServlet pretty well these days.
For AJP setup, see the documentation here:
https://tomcat.apache.org/tomcat-4.0-doc/config/ajp.html

Possibly Port Error

I already installed Tomcat server while developing my java web app. But I also needed to get access to my database using PHPMyAdmin and install MySQL as well, so I downloaded XAMPP. I cannot disable apache server since I already have Tomcat. Now my struggle is, I cannot open
"localhost:8080" which was my original port. It's now replaced with simply "localhost".
Can you help me fix this error? THANK YOU :D
Sounds like you now have:
Tomcat serving traffic on port 8080, as it always has (at http://localhost:8080)
Apache/XAMPP serving traffic on port 80 (at http://localhost, obviously with the port missing since 80 is the default http port)
Assuming that's the case, you don't have a problem. Serving http traffic from different ports on the same host is not an issue.