使用letencrypt重定向https tp http的https virtualhost apache代理后面的http nginx dockers

时间:2018-12-21 13:45:20

标签: apache docker nginx reverse-proxy lets-encrypt

我在Debian VPS中安装了Apache服务器,我将其用作与包含静态网站的Nginx容器相反的代理,我将容器的端口80映射到3002且其工作正常,但是当我访问{ {3}}会将我重定向到https://www.example.com!我将我的虚拟主机设置为:

第一个vHost(HTTP)

<VirtualHost *:80>
   ServerName example.com
   <Location />
     Order allow...
   </Location>
   ProxyRequests Off
   ProxyPreserveHost On
   #proxy to docker nginx -p 3002:80
   ProxyPass / http://localhost:3002
   ProxyPassReverse / http://localhost:3002

</VirtualHost>

第二个vHost(由Letencrypt Bot创建的HTTPS)

<VirtualHost *:443>
       ServerName example.com
       <Location />
         Order allow...
       </Location>
       ProxyRequests Off
       ProxyPreserveHost On
       #proxy to docker nginx -p 3002:80
       ProxyPass / http://localhost:3002
       ProxyPassReverse / http://localhost:3002
       #crt files..
       SSLCertificateFile /etc/letsen...
       SSLCertificateKeyFile /etc/letsen..
       Include /etc/letsencrypt/option...
</VirtualHost>
  

注意:Docker映像为kyma / docker-nginx

1 个答案:

答案 0 :(得分:0)

您需要www的别名:

ServerName: example.com 
ServerAlias: www.example.com