I'm trying to create a proxy in Java which proxies HTTP and HTTPS URLs. (I'm using Tomcat 8.0.14. I have set up Tomcat to receive HTTPS connections on port 8443, although this shouldn't be necessary to use Tomcat as an HTTPS proxy. But either way I get the same behaviour.) I've got it working using HTTP, but when I use HTTPS, it seems that Tomcat just rejects the connection and doesn't even call my servlet.
To illustrate this, I've created an example "Hello World" servlet mapped to "/*" in my web.xml.
public class HelloWorldProxy extends HttpServlet {
@Override
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
System.out.println("Hello, World! " + ((new Date()).toString()));
super.service(req, res);
}
}
I set "localhost:8080" as the proxy for HTTP and HTTPS requests in Firefox as a test. Behaviour:
- When I hit "http://www.bbc.co.uk/", I get "Hello, World! ...." in the console as expected.
- When I hit "https://github.com/", I don't get any console output.
Does anyone know why this is?