tags:

views:

324

answers:

2

I configure a default tomcat installation (running on "localhost" at port "8080") as a proxy server in my browser and try to connect to http://www.google.com.

I would expect either an error message saying tomcat is not configured as a proxy server or I should get the contents of google website.

Instead I get the index.html page of my tomcat installation.

What is going wrong?

A: 

All a proxy server does is pass requests and responses through. From your browser's perspective, you requested a URL, the proxy server returned HTML and a code 200, so this is interpreted as the response from the requested URL. Since this is a static page and not a real proxy server, all requests will result in the same static response.

davogones
If I access http://www.google.com/examples, I see the example application of my deployed tomcat. This makes no sense to me.I agree that the browser just faithfully displays contents. My issue is with tomcat, which has been configured as the proxy server.
Raghuram
How did you configure it as a proxy server? Depending on how you set it up, it might only be a proxy for certain web apps, or it might be running on another port.
davogones
I am doing nothing in tomcat. I am configuring this tomcat as a proxy server on my browser. This is to check what should be the behavior when the server receives a proxy request it is incapable of honoring. When I do the following GET http://www.google.com/myapp HTTP/1.1I am wondering why tomcat should ignore the leading URL and process the request as /myapp?
Raghuram
I see... You're right, that is odd. Normally the server should reject the request, but for some reason Tomcat is processing it and returning the default page. Well, at least I understand your question now!
davogones
Well, I set up a vanilla tomcat and configured it as my browser's proxy, and I got the same result as you. Next step is to find out why it does that!
davogones
A: 

Tomcat doesn't have any built-in proxy function. I don't know what configuration you are talking about.

The browser will request an URI like "http://google.com/examples". If the Tomcat is configured with a default host and default welcome page, it will be displayed. It doesn't understand the proxy request at all.

You have to install a proxy servlet and map it to the root to use Tomcat as a proxy server.

ZZ Coder