[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to configure Apache web server to handle Tomcat 302 response code?

Posted on 2011-05-03
2
Medium Priority
?
1,324 Views
Last Modified: 2013-12-24
Our application is hosted in Apache 2.2.10 Web server. Load balancing is configured in virtual host.

Usual URL requests of the application are of the kind /InfoViewApp/?0.2322. But, after a patch, the URL structure has a error : /InfoViewApp?0.621367810784860 The ' / ' is missing before the ' ? '.

What happens When the requests are forwarded directly to Tomcat?

1. The URL request that is problematic has now got a request similar to below:

/InfoViewApp?0.621367810784860

But, the original request should be /InfoViewApp/?0.6213678107848606


2. Because of this, HTTP response code 302 is thrown (i.e., moved temporarily).


3. The client side browser (eg., internet explorer) is capable of handling the 302 response codes :

The URL is then corrected by the browser and request is redirected as /InfoViewApp/?0.6213678107848606. So, the correct request yields a HTTP response code of 200 (i.e., successful response)


So what happens when requests go via Apache?
 

1.    The invalid URL - /InfoViewApp?0.6213678107848606 is passed on to Apache.

2.    Apache passes this request to Tomcat via load balancer.

3.    Tomcat throws 302 response code back to Apache(in this case not passed on directly to the browser that can handle 302).

4.    But, the problem lies that : Apache redirect for response code 302 is not configured in the config file. So connection to the server is reset and we get PING error in our browser. Only, if this is configured, Apache can handle the 302 code without throwing error.

How to configure the redirect?

I tried out the following with no success :

RewriteEngine on

RewriteRule ^/InfoViewApp(\?.*)$ https://domain/InfoViewApp/$1 [R=302,L]

Please help in sorting out this issue.

Regards
Harish
0
Comment
Question by:harish_ravi
2 Comments
 
LVL 5

Accepted Solution

by:
SimonDard earned 2000 total points
ID: 35513543
You seem to want to catch wrong URLs, e.g.: /infoViewApp?0.6213678107848606 Right ones (with the added / ) should pass:

RewriteRule ^/InfoViewApp$ https://domain/InfoViewApp/

The querysting (question mark and everything behind it) are not matches by rewriterules. In your case, they don't have to be matches, just passed on. Add a QSA (querystring attach) to the rewriterule and a L (do an immediate rewrite, 302 is default so R is not needed):

RewriteRule ^/InfoViewApp$ https://domain/InfoViewApp/ [L,QSA]
0
 

Author Comment

by:harish_ravi
ID: 35697729
Thanks a lot Simon,

This seems to work now.

Anyway let me o some more testings and then we can conclude :)

Regards
Harish
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing is at the top of most security top 10 efforts you should be pursuing in 2016 and beyond. If you don't have phishing incorporated into your Security Awareness Program yet, now is the time. Phishers, and the scams they use, are only going to …
In this article, I’ll show how research, determination, and use of modern technology helped me solve a DNA mystery.
The Bounty Board allows you to request an article or video on any technical topic, or fulfill a bounty request to earn points. Watch this video to learn how to use the Bounty Board to get the content you want, earn points, and browse submitted bount…
Articles on a wide range of technology and professional topics are available on Experts Exchange. These resources are written by members, for members, and can be written about any topic you feel passionate about. Learn how to best write an article t…

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question