通过配置Apache的.conf文件重定向HTTP到HTTPS(Redirect http to h

2019-09-16 19:16发布

我必须配置Apache通过代码Tomcat的配置一样

<VirtualHost *:80>
ServerName captiveportal
ProxyPass       / http://ip:port/path
ProxyPassReverse / http://ip:port/path
</VirtualHost>

现在,我想这reirect要求HTTPS我怎样才能做到这一点?

寻找你的答案后,我有改变了我的配置一样

<VirtualHost *:443>
SSLEngine on
SSLCertificateFile "/etc/httpd/conf/crt1.crt"
SSLCertificateKeyFile "/etc/httpd/conf/key1.key"
ProxyPass       / http://ip:port/path
</VirtualHost>
<VirtualHost *:80>
ServerName captiveportal
Redirect / https://ip:port/path
</VirtualHost>

但是当我键入captiveportal在我的浏览器,它重定向我的URL https://ip:port/path ,并显示problem loading page

还有一两件事,我不希望显示https://ip:port/path上的浏览器。

注: - https://ip:port/path ,其中端口是我的tomcat的端口和IP为机的ip tomcat的地方跑。

Answer 1:

你可以这样做:

<VirtualHost *:80>
   ServerName captiveportal
   Redirect / https://my.host.name/
</VirtualHost>

...然后把你ProxyPass指令在侧的SSL VirtualHost块来代替。



文章来源: Redirect http to https by configuring .conf file of apache