【问题标题】:jhipster ssl ubuntu apache2 setupjhipster ssl ubuntu apache2 设置
【发布时间】:2018-12-10 04:54:57
【问题描述】:

我使用 Jhipster 生成了我的应用程序。将其配置为使用 Ubuntu 16.x 和 apache 在 amazon ec2 上运行,并使用以下配置和 Godaddy 记录。当我点击网站网址时,它会毫无问题地映射和呈现网站。

apache2 配置

<VirtualHost *:80>
    ServerName 111.22.33.444
    ProxyPreserveHost On
    ProxyRequests Off

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass / http://111.22.33.444:8080/
    ProxyPassReverse / http://111.22.33.444:8080/

</VirtualHost>

嵌套步骤,尝试配置 SSL。我从 godaddy 为我的域购买了 SSL,对其进行了配置并将 *.crt 文件上传到 /etc/apache2/ssl。我很快意识到,仅仅通过为端口 443 添加另一个虚拟主机配置将不起作用,因为 JHipster 应用程序在 8080 上运行。我回去查看https://www.jhipster.tech/production/,他们有使用 HTTPS 配置与前端配置 SSL 的说明结束代理,这是我迷路的地方,无法配置 SSL 并在 https 上提供我的域。

不清楚的是,我是否仍可以在 8080 上运行该应用程序并只需按照 带有前端代理的 HTTPS 配置下的说明进行操作?首先,我使用以下命令使用“lets encrypt”配置 apache

sudo certbot --apache -d doamin.com --agree-tos -m info@domain.com --redirect

它说失败了

domain.com 重定向失败

无法为 domain.com 设置增强重定向

没用。

我需要对 Jhipster 应用程序进行哪些更改?它应该在 443 上运行还是继续运行 8080 并更新虚拟主机配置?如何配置虚拟主机?

我在没有任何指示的情况下搜索了高低。任何方向都非常感谢。

【问题讨论】:

  • 您是否尝试过不带 --redirect 参数的lets-encrypt?我猜它失败了,因为您没有在现有虚拟主机中声明任何主机(或者您可能删除了它们?)。您的设置看起来正确(http 请求 -> apache -> jhipster 应用程序)
  • @JonRuddell 感谢您的回复。没错,我的虚拟主机中没有声明任何主机。我尝试了不同的组合,包括让加密没有运气。即使lets-encrypt给出错误消息,它确实会更新443的虚拟主机条目。我的问题是我可以在8080上运行应用程序并仍然配置HTTPS吗?如果是这样,apache配置应该是什么?

标签: spring-boot ssl apache2 ubuntu-16.04 jhipster


【解决方案1】:

假设您的应用在 http://127.0.0.1:8080/ 上可用,您可以按照以下步骤使用 Certbot 成功配置 Apache 的 HTTPS。

设置服务器:

sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-apache apache2

从配置开始:

<VirtualHost *:80>
        ServerName example.com
        ServerAlias example.com

        ProxyPass / http://127.0.0.1:8080/
        ProxyPassReverse / http://127.0.0.1:8080/

        ProxyPreserveHost On
        ProxyRequests Off

</VirtualHost>

启用插件并重新启动 Apache2,使应用可以在上面配置的域中访问:

a2enmod headers proxy proxy_http
service apache2 restart

然后用the instructions in the docs运行certbot:

sudo certbot --apache -d example.com

之后,您的应用将可以通过 HTTPS 在您配置和提供的域中访问。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-22
    • 2021-02-27
    • 2018-01-17
    • 1970-01-01
    • 2015-11-20
    • 2015-07-14
    • 2020-11-18
    • 1970-01-01
    相关资源
    最近更新 更多