在我的情况下,我需要向我的apache 2.4 vhost文件添加SSLProxyEngine On,ProxyPreserveHost On和 RequestHeader将Front-End-Https设置为“ On”,因为我想在docker容器上启用SSL。关于local.hostname.ofDockerHost,在我的情况下,运行docker容器的主机服务器的名称为lucas,映射到docker容器的端口443的端口为1443(因为主机中的apache已在使用端口443服务器),因此该行以这种方式结束https:// lucas:1443 /
这是最终设置,并且工作正常!
<VirtualHost *:443> # Change to *:80 if no https required
ServerName www.somewebsite.com
<Proxy *>
Allow from localhost
</Proxy>
SSLProxyEngine On # Comment this out if no https required
RequestHeader set Front-End-Https "On" # Comment this out if no https required
ProxyPreserveHost On
ProxyPass / http://local.hostname.ofDockerHost:12345/
ProxyPassReverse / http://local.hostname.ofDockerHost:12345/
</VirtualHost>
最后,在Docker容器中,我必须设置代理SSL标头。以我为例,该容器运行的是nginx和称为omnibus的东西,用于设置ruby应用程序。我认为这也可以在Nginx配置文件中设置。将其记录下来,以防万一有人觉得有帮助
nginx['redirect_http_to_https'] = true
nginx['proxy_set_headers'] = {
"Host" => "$http_host",
"X-Real-IP" => "$remote_addr",
"X-Forwarded-For" => "$proxy_add_x_forwarded_for",
"X-Forwarded-Proto" => "https",
"X-Forwarded-Ssl" => "on"
}
nginx['real_ip_trusted_addresses'] = ['10.0.0.77'] # IP for lucas host
nginx['real_ip_header'] = 'X-Real-IP'
nginx['real_ip_recursive'] = 'on'
有关Apache,ISP配置,Ubuntu服务器16.04的完整指南,请参见此处https://www.howtoforge.com/community/threads/subdomain-or-subfolder-route-requests-to-running-docker-image.73845/#post-347744