我有两个AWS EC2实例,一个Web服务器和一个应用程序服务器。我的主页在我的Web服务器上。在使用SSL之前,我可以使用以下方法从主页访问应用服务器上的页面:
http://homePage.com/app1/page.php
我的proxy-host.conf具有以下内容
<virtualhost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPreserveHost On
# Servers to proxy the connection, or
# List of application servers Usage
ProxyPass /app1/ http://10.0.1.22:80/
# ProxyPass /app1/ http://10.0.1.22:443/
</virtualhost>
从那以后,我更改了/etc/apache2/ports.conf和/etc/apache2/httpd.conf,因此我的主页始终使用端口443的SSL。我创建了一个具有以下内容的proxy-ssl-host.conf文件。
<virtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine On
# Set the path to SSL certificate
# Usage: SSLCertificateFile /path/to/cert.pem
SSLCertificateFile /etc/apache2/ssl/homepage.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/homepage.com.key
ProxyPreserveHost On
ProxyPass /app1/ https://10.0.1.22:443/
ProxyPassReverse /app1/ https://10.0.1.22:443/
ServerName localhost
</VirtualHost>
制作proxy-ssl-host.conf之后,我输入了以下内容
sudo a2ensite proxy-ssl-host.conf
sudo service apache2 reload
sudo systemctl restart apache2.service
现在,当我进入浏览器并输入
https://homePage.com/app1/page.php
我懂了
The requested URL /app1/page.php was not found on this server.
Apache/2.4.18 (Ubuntu) Server at homePage.com Port 443
编辑1:
我试过
sudo netstat -ntpl | grep :443
在应用程序服务器上并没有任何响应,因此apache不在该服务器上的端口443上进行侦听。我加了
Listen 443
后
Listen 80
在ports.conf中,现在获取
tcp6 0 0 :::443 :::* LISTEN 2205/apache2
后
sudo netstat -ntpl | grep :443
不幸的是,这并没有解决我在浏览器上的任何问题。
编辑2:
当我进入网络服务器并进入
wget https://10.0.1.22/page.php
我有
--2018-02-18 20:58:32-- https://10.0.1.22/page.php
Connecting to 10.0.1.22:443... connected.
OpenSSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Unable to establish SSL connection.
当我进入
wget https://10.0.1.22/app1/page.php
我有
--2018-02-18 20:59:37-- https://10.0.1.22/app1/page.php
Connecting to 10.0.1.22:443... connected.
OpenSSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Unable to establish SSL connection.
当我进入
wget http://10.0.1.22
我有
--2018-02-18 19:32:45-- http://10.0.1.22/
Connecting to 10.0.1.22:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4198 (4.1K) [text/html]
Saving to: ‘index.html’
index.html 100%[=====================================================================================>] 4.10K --.-KB/s in 0s
2018-02-18 19:32:45 (564 MB/s) - ‘index.html’ saved [4198/4198]
在地下室的DMZ上设置SSL时,我只需要在Web服务器上安装SSL证书,它们也将在我的应用程序服务器上生效。但是,在我的地下室中,它们具有相同的公共IP地址。Web服务器还运行CentOS,而应用程序服务器则运行Debian。使用我的云DMZ,它们具有不同的IP地址,并且都在Ubuntu上运行。我想知道是否需要在我的应用程序服务器上设置证书,就像在Web服务器上设置证书一样。
我想到了。
我应该将ProxyPass放在块外。这将错误更改为此处概述的错误。我使用了他们的解决方案,现在错误更改为此处概述的解决方案。我使用了他们的解决方案,这完全解决了我的问题。
因此,/etc/apache2/sites-available/proxy-host.conf变为
SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
ProxyPass /app1/ https://ip-10-0-1-22/
<virtualhost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPreserveHost On
# Servers to proxy the connection, or
# List of application servers Usage
ProxyPass /app1/ https://ip-10-0-1-22.ec2.internal/
</virtualhost>
和/etc/apache2/sites-available/proxy-ssl-host.conf成为
SSLProxyEngine on
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
ProxyPass /app1/ https://ip-10-0-1-22/
ProxyPassReverse /app1/ https://ip-10-0-1-22/
<virtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine On
# Set the path to SSL certificate
# Usage: SSLCertificateFile /path/to/cert.pem
SSLEngine on
SSLProxyEngine On
ProxyRequests Off
SSLCertificateFile /etc/apache2/ssl/clusterprism.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/clusterprism.com.key
ProxyPass /app1/ https://ip-10-0-1-22.ec2.internal/
ProxyPassReverse /app1/ https://ip-10-0-1-22.ec2.internal/
ServerName localhost
</VirtualHost>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句