【问题标题】:How to enable Apache SSL Reverse Proxy on HTTP application如何在 HTTP 应用程序上启用 Apache SSL 反向代理
【发布时间】:2015-11-05 05:06:15
【问题描述】:

我在尝试在 Apache 上为 Ubuntu 14.04 上的 HTTP 应用程序实现反向 SSL 代理时遇到问题。作为基线,当我通过浏览器中的端口 8000 正常访问应用程序时,应用程序运行良好。出于所有意图和目的,假设我的应用程序的 IP 是 192.141.56.11(我还没有域名)。该应用程序使用 HTTP Basic Auth 运行,我不知道它是否相关。基本上我在这里寻找一些明显的错误,如果你能帮助我,我将不胜感激。这是我的过程的日志:

我创建了我的 SSL 证书和密钥并将它们放在以下位置:

/etc/apache/ssl/apache.crt (I performed chmod 644 here)
/etc/apache/ssl/apache.key (I performed chmod 400 here)

然后我安装了:

apt-get install apache2
a2enmod proxy
a2enmod ssl
a2enmod proxy_http

然后我禁用了默认配置:

a2dissite 000-default

我创建了文件“/etc/apache2/sites-available/redirect.conf”

然后我创建了文件“/etc/apache2/sites-available/redirect.conf”并复制了以下文本:

<VirtualHost *:80>
    Redirect "/" "https://192.141.56.11"
</VirtualHost>

之后,我创建了文件“/etc/apache2/sites-available/reverse_proxy.conf”并复制如下:

<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache/ssl/apache.crt
SSLCertificateKeyFile /etc/apache/ssl/apache.key
ProxyPass / http://127.0.0.1:8000/
ProxyPassReverse / http://127.0.0.1:8000/

并且做到了:

service apache2 restart

我现在尝试在 Chrome 浏览器中访问另一台机器上的应用程序 UI。尝试时:

https://192.141.56.11

我收到一般 SSL 连接错误。

但是,尝试

http://192.141.56.11:8000

给了我应用程序,好像我的配置没有任何改变。然而,

192.141.56.11:80

给我一​​个“索引”页面,其中包含一个 html 文件夹,上面写着“Apache/2.4.7 (Ubuntu) Server at 192.141.56.11 Port 80”

192.141.56.11:443

除了“Apache/2.4.7 (Ubuntu) Server at 192.141.56.11 Port 443”之外,给出了相同的结果

我已经尝试了各种配置方式,但无法得到我想要的——这里有什么想法吗?

【问题讨论】:

    标签: apache ssl proxy


    【解决方案1】:

    编辑:我尝试了 https[:]//192.141.56.11 并得到了更具体的 SSL 错误:

    received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long) 
    

    EDIT2:运行 apache 后,我收到此警告;

    apache2: Could not reliably determine the server's fully qualified domain        name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
    

    我想这很好,因为我使用的是 IP 而不是域名。

    EDIT3:事实证明我需要这样做:

    a2ensite reverse_proxy.conf.
    

    现在 https[:]//192.141.56.11 可以工作,但默认为 apache 页面。正在处理这个问题。

    EDIT4:我必须这样做 a2dissite default-ssl.conf

    现在它实际上重定向到 https[:]//192.141.56.11 上的应用程序!但是我仍然可以通过端口 8000 访问该应用程序,这很糟糕{仍在工作}

    EDIT5:最后,我不知道如何阻止通过 Apache 上的端口 8000 访问原始应用程序。相反,我只是在服务器上实现了 iptables,因此它只能通过 HTTPS 访问。这可能不是正确的方法。但我能想到的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多