如何在HTTP应用程序上启用Apache SSL反向代理

时间:2015-11-05 05:06:16

标签: apache ssl proxy

我在尝试在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>

之后,我创建了文件&#34; /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

给了我一个&#34;指数&#34;页面上有一个html文件夹,上面写着&#34; Apache / 2.4.7(Ubuntu)服务器,位于192.141.56.11端口80&#34;

192.141.56.11:443

给了我相同的结果,除了#34; Apache / 2.4.7(Ubuntu)服务器在192.141.56.11端口443&#34;

我已尝试过所有配置方式,但无法获得我想要的内容 - 这里有任何想法吗?

1 个答案:

答案 0 :(得分:0)

编辑:我尝试了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页面。正在努力。

编辑4:我必须这样做     a2dissite default-ssl.conf

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

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