Apache Reverse Proxy with SSL

回覆文章
Lexaul
文章: 231
註冊時間: 2019-10-18, 14:28

Apache Reverse Proxy with SSL

文章 Lexaul » 2020-03-17, 16:26

[APACHE] REVERSE PROXY 反向代理設定

1.
要架設的話首先要去httpd.conf開啟幾個模組

代碼: 選擇全部

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
2.
設定httpd-vhosts.conf

<VirtualHost *:80>
ServerName aaa.cystar.nctu.me
#因為只是Reverse,因此ProxyRequests要關閉
ProxyRequests off
<Proxy *>
Order allow,deny
Allow from all
</Proxy>

ProxyPass / http://192.168.0.100/
ProxyPassReverse / http://192.168.0.100/
ProxyPreserveHost on
</VirtualHost>


以上僅設定http 非 https
如何設定SSL呢

apache reverse proxy with ssl設定
SSL描述:

<VirtualHost *:443>
ServerName aaa.cystar.nctu.me
SSLEngine On
SSLProxyEngine On
SSLCertificateFile /localpath/certificate.crt
SSLCertificateKeyFile /localpath/private.key
SSLCACertificateFile /localpath/ca_bundle.crt

ProxyRequests Off
ProxyPass / https://192.168.0.100/
ProxyPassReverse / https://192.168.0.100/
ProxyPreserveHost On
</VirtualHost>

出現Error during SSL Handshake with remote server錯誤
Error during SSL Handshake with remote server

解答如下:
The comment by MK pointed me in the right direction.
In the case of Apache 2.4 and up, there are different defaults and a new directive.
I am running Apache 2.4.6, and I had to add the following directives to get it working:

代碼: 選擇全部

SSLProxyEngine on
SSLProxyVerify none 
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
因此最後的程式碼為

代碼: 選擇全部

<VirtualHost *:443>
ServerName  aaa.cystar.nctu.me
SSLEngine On
SSLProxyEngine On
SSLProxyVerify none 
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire of
SSLCertificateFile /localpath/certificate.crt
SSLCertificateKeyFile /localpath/private.key
SSLCACertificateFile /localpath/ca_bundle.crt
ProxyRequests Off
ProxyPass / https://192.168.0.100/
ProxyPassReverse / https://192.168.0.100/
ProxyPreserveHost On
</VirtualHost>
[email protected]
github.com/Lexaul

回覆文章