首页 文章

apache 2.4.6代理https到http Tomcat 7.0.68

提问于
浏览
0

我有一个在上下文“/ mycontext”运行的Tomcat应用程序 . Apache 2.4.6通过httpd.conf中的代理处理前端 . 我无法使用带有CA签名证书的https在/ mycontext上呈现页面 .

<VirtualHost *:80>
  ServerName www.example.com
  ServerAlias *.example.com
  ProxyRequests off
  ProxyPass         /mycontext  http://example.com:8081/mycontext
  ProxyPassReverse  /mycontext  http://example.com:8081/mycontext
</VirtualHost>

发送为http://example.com/mycontext的请求将按预期呈现 .

对于/ mycontext的某些页面,我们希望使用SSL进行连接 . 示例:https://example.com/mycontext/transaction.xhtml使用CA签名证书 .

对于https:

<VirtualHost *:443>
  ProxyRequests off
  ProxyPreserveHost on
  SSLEngine on
  SSLCertificateFile /path/to/certs/ca.crt
  SSLCertificateKeyFile /path/to/key/private/mykey.key
  ServerName www.example.com
  ServerAlias *.example.com
  ProxyPass /mycontext http://example.com:8081/mycontext
  ProxyPassReverse /mycontext http://example.com:8081/mycontext
</VirtualHost>

server.xml中的我的Tomcat连接器:

<Connector port="8081" protocol="HTTP/1.1"
        connectionTimeout="20000"
        proxyName="www.example.com"
        proxyPort="80"
        redirectPort="8443"
        xpoweredBy="false"
        server="Apache TomEE" />

*编辑 - 由于我无法让代理重定向到端口8081的连接器,我在Tomcat的server.xml中使用端口8082和proxyPort = 443定义了第二个连接器 . 仍然没有成功 .

<Connector port="8082" protocol="HTTP/1.1"
    connectionTimeout="20000"
    proxyName="www.example.com"
    proxyPort="443"
    redirectPort="8443"
    xpoweredBy="false"
    server="Apache TomEE" />

https://example.com/mycontext的请求导致Apache响应:

未找到

在此服务器上找不到请求的URL / mycontext / .

这是一个缺少或错误设置的虚拟主机指令问题吗? SSL证书已正确安装,显示锁定图标“Verified by ....” .

1 回答

  • 0

    SSL虚拟主机未正确代理,您必须匹配斜线或缺少斜线 . 所以你必须使用:

    ProxyPass /mycontext http://example.com:8081/mycontext
    

    这是您在非SSL虚拟主机中使用的,不知道为什么您在SSL虚拟主机中更改了它,因为您描述的是您想要执行相同的操作 .

相关问题