【发布时间】:2018-08-23 01:18:29
【问题描述】:
我正在努力使用代理在 Apache 中反转 SSL 服务器。
现在我在一个域中的许多子域下有许多网站。
例如:
gitlab.mydomain.com
nextcloud.mydomain.com
plex.mydomain.com
所有网站都使用 Letsencrypt 证书,因此它们都启用了 HTTPS。
问题是,到目前为止,在我的本地主机上运行的服务器都不是 HTTPS。例如,Plex 在我的本地主机上作为独立的 HTTP 服务器运行,我只是使用 Apache 进行反向代理,并在互联网上使用 Letsencrypt 保护它。
现在我需要代理反向一个已经安全的 HTTP 服务器。即 Jenkins - 由于各种原因,它在我的本地主机上与 Letsencrypt 一起运行。我还应该提到,用于在 localhost 上加密它的证书与我在 Apache 中使用的证书相同。
所以我的 Jenkins 在端口 8443 上运行,我的 Jenkins 的 Apache 配置如下:
# Just to redirect HTTP to HTTPS
<VirtualHost *:80>
ServerName jenkins.mydomain.com
ServerAlias www.jenkins.mydomain.com
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>
<Virtualhost *:443>
ServerName jenkins.mydomain.com
ServerAlias https://jenkins.mydomain.com
ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Proxy https://localhost:8443/jenkins*>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /jenkins http://localhost:8443/jenkins nocanon
ProxyPassReverse /jenkins http://localhost:8443/jenkins
ProxyPassReverse /jenkins http://jenkins.mydomain.com/jenkins
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"
RequestHeader set X-Forwarded-Ssl on
RewriteEngine on
RewriteRule "^/$" "/jenkins/" [R]
SSLEngine on
SSLCertificateFile path/to/fullchain.pem
SSLCertificateKeyFile path/to/privkey.pem
</Virtualhost>
但是,使用此配置时,我收到 错误 502(代理错误):
代理服务器收到来自上游服务器的无效响应。 代理服务器无法处理请求 GET /jenkins/。 原因:从远程服务器读取错误
【问题讨论】:
标签: apache ssl jenkins reverse-proxy