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?
Tomcat doesn’t know that it’s supposed to proxy the request. All it knows is that your browser showed up and asked it for something, like this:
With Apache HTTPD, you might have configuration such that when a request shows up for a host that’s not itself, it acts as a proxy for the request.
Tomcat is not generally used as a proxy. Tomcat is however frequently used behind a reverse proxy where the request may be for something like “www.google.com” which may be relayed back to Tomcat as the site it’s supposed to be serving. Tomcat’s standard configuration pretty much accepts the host specified as its own, and adopts it for the purpose of creating absolute references to itself, with the assumption that if a request got to it, it was legitimate. You can of course alter this behavior with configuration, but if you don’t, Tomcat is pretty much going to try to serve what you requested from its set of applications, assuming you knew what you were doing with the Host header.