
我有一台使用 Apache 的伺服器作為對 Node Web 服務的請求的代理。我目前可以使用本地網路以外的瀏覽器使用我的網域進行連線:https://mydomain.ca
。我相信我用過的能夠使用本機網路內的瀏覽器使用伺服器的本機 IP 位址進行連線:https://10.0.0.13
。但是,當我現在嘗試時,我收到 500 錯誤。我正在尋求幫助以使其再次發揮作用。http://10.0.0.13
如果更容易實現的話,我也可以不在本機網路上使用 SSL 並存取伺服器。
我收到以下帶有 500 錯誤的文字:
The proxy server could not handle the request
Reason: Error during SSL Handshake with remote server
我在 Apache 錯誤日誌 (/var/log/apache2/error.log) 中尋找更多線索,但沒有找到超級有用的文字:
[Sun Nov 28 23:11:42.609115 2021] [proxy_http:error] [pid 28560:tid 140085584455424] [client 10.0.0.220:26070] AH01097: pass request body failed to 127.0.0.1:4201 (loca lhost) from 10.0.0.220 ()
[Sun Nov 28 23:11:42.769782 2021] [proxy:error] [pid 28560:tid 140085567670016] (20014)Internal error (specific information not available): [client
10.0.0.220:26071] AH 01084: pass request body failed to 127.0.0.1:4201 (localhost)
[Sun Nov 28 23:11:42.769805 2021] [proxy:error] [pid 28560:tid 140085567670016] [client 10.0.0.220:26071] AH00898: Error during SSL Handshake with remote server returne d by /
這是我的conf檔的樣子:
mydomain.ca-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName mydomain.ca
ServerAlias www.mydomain.ca
ProxyPreserveHost on
SSLProxyEngine on
ProxyPass / https://localhost:4201/
ProxyPassReverse / https://localhost:4201/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerAlias mydomain.ca
SSLCertificateFile /etc/letsencrypt/live/mydomain.ca/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.ca/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
mydomain.ca.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName mydomain.ca
ServerAlias www.mydomain.ca
DocumentRoot /var/www/mydomain.ca
ProxyPreserveHost on
ProxyPass / http://localhost:4201/
ProxyPassReverse / http://localhost:4201/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
編輯 - 以下是有關 Node Web 服務的一些資訊: Node Web 服務正在偵聽單個端口,並且僅偵聽 https 連接。
答案1
您已將 HTTP 和 HTTPS 設定為連接到後端伺服器上的相同連接埠。
您的後端伺服器不太可能在同一連接埠上支援這兩種協定。
在兩個 VirtualHost 中使用 HTTP,或者如果您的後端伺服器支援兩者,請使用正確的 HTTPS 連接埠。
答案2
上面的一些評論讓我以正確的方式思考這個問題。我採用的方法是
- 在我的 Node Web 服務中的不同連接埠上執行單獨的 http 和 https 伺服器,
- 更新 mydomain.ca.conf 和 mydomain.ca-le-ssl.conf 中的連接埠號碼以對應正確的連接埠號,以及
- 更新 mydomain.ca.conf 以僅回應來自本機或 LAN 的請求,如下所示。
<VirtualHost *:80> # We should only access the web server via http if on localhost # or within LAN. <Location /> Require local Require ip 10.0.0.0/24 </Location> ...
完成所有這些後,我現在可以http://10.0.0.13
從本地網路內部和https://mydomain.ca
本地網路外部進行存取。