【问题标题】:Spring Boot SSL behind Apache2 serverApache2 服务器后面的 Spring Boot SSL
【发布时间】:2020-09-03 10:20:22
【问题描述】:

我有一个设置了 SSL 处理的 Spring Boot 应用程序。我正在使用 iptables 重新路由将所有端口 80 流量路由到 Spring Boot 端口 8080,并将所有 443 流量路由到 Spring Boot 8443。

Spring Boot 然后将任何 http 流量重定向到 https (443)。一切正常。

现在我想运行一个 Apache2 服务器并使用它将流量重定向到 Spring Boot,而不是直接使用 iptables 重新路由。

我已经为该站点创建了以下 conf 文件:

<VirtualHost *:80>
    ServerAdmin mail@gmail.com
    ProxyPreserveHost On
    ProxyRequests Off

    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/

    ErrorLog ${APACHE_LOG_DIR}/site/error.log
    CustomLog ${APACHE_LOG_DIR}/site/access.log combined
</VirtualHost>

<VirtualHost _default_:443>
    ServerAdmin mail@gmail.com
    ProxyPreserveHost On
    ProxyRequests Off

    ProxyPass / https://localhost:8443/
    ProxyPassReverse / https://localhost:8443/

    ErrorLog ${APACHE_LOG_DIR}/site/error.log
    CustomLog ${APACHE_LOG_DIR}/site/access.log combined

</VirtualHost>

但它似乎不起作用。我收到“此站点无法提供安全连接”。尽管从 http 到 https 的重定向(在 spring boot 中设置)似乎确实有效。

我在 google 上找到的大部分内容都展示了如何在 Apache2 后面配置 Spring Boot,并由 Apache2 处理 ssl。我如何设置它以便它是处理 ssl 的 spring boot,而 Apache 基本上只是做端口映射。或者设置 Apache 来处理 ssl 会不会那么痛苦?

【问题讨论】:

    标签: apache spring-boot ssl https proxy


    【解决方案1】:

    看起来我想要的是 Apache2 不支持的“通过 SSL 代理”。

    环顾四周,Nginx 确实支持这样的东西:https://serversforhackers.com/c/tcp-load-balancing-with-nginx-ssl-pass-thru

    但即便如此,也会有额外的复杂性,因为这使得服务器很难确定请求被发送到哪个主机,因为它无法解密加密的请求

    在 Spring Boot 之前设置 Web 服务器的目的是在该服务器上托管多个站点,所以我想我将设置 Apache2 来终止 SSL。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-20
      • 2019-01-01
      • 2016-03-22
      • 2019-03-18
      • 2018-07-05
      • 1970-01-01
      • 2022-01-19
      • 2014-12-20
      相关资源
      最近更新 更多