简体   繁体   English

如何获得Tomcat(等)来接受HTTPS代理请求?

[英]How can I get Tomcat (etc) to accept HTTPS proxy requests?

I'm trying to create a proxy in Java which proxies HTTP and HTTPS URLs. 我正在尝试在Java中创建代理,以代理HTTP和HTTPS URL。 (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. (我正在使用Tomcat 8.0.14。我已经将Tomcat设置为在端口8443上接收 HTTPS连接,尽管使用Tomcat作为HTTPS代理不是必须的。但是无论哪种方式,我都可以得到相同的行为。)使用HTTP可以正常工作,但是当我使用HTTPS时,Tomcat似乎只是拒绝连接,甚至不调用我的servlet。

To illustrate this, I've created an example "Hello World" servlet mapped to "/*" in my web.xml. 为了说明这一点,我创建了一个示例“ Hello World” servlet,该示例映射到我的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. 作为测试,我将“ localhost:8080”设置为Firefox中HTTP和HTTPS请求的代理。 Behaviour: 行为:

Does anyone know why this is? 有人知道为什么是这样吗?

For me it so far not clear which part of the connection is not working. 对我而言,到目前为止,尚不清楚连接的哪一部分无法正常工作。 As far as I understood your setup looks like 据我了解,您的设置看起来像

client <---> my-tomcat-proxy <---> some webpage 客户端 <---> my-tomcat-proxy <---> 某些网页

If the https connection between the client and your tomcat does not work, you maybe need to extend you tomcat config xml with an SSL connector, see Apache Tomcat 6.0 SSL Configuration HOW-TO for more details. 如果客户端和您的tomcat之间的https连接不起作用,则可能需要使用SSL连接器来扩展tomcat config xml,有关更多详细信息,请参阅Apache Tomcat 6.0 SSL Configuration HOW-TO

I had the same problem that my tomcat did not reply to client-side https requests. 我有一个同样的问题,就是我的tomcat无法回复客户端https请求。 My problem was that I did not configure the tomcat properly to accept https connections. 我的问题是我没有正确配置tomcat以接受https连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM