我正在使用Apache作为我的Web应用程序的代理服务器,在Glassfish容器中运行。 我在Apache中configuration了代理密码和SSL。 该网站可以从外部访问URL https://www.my-domain.com没有任何问题。 但是我想在浏览器上调用没有前缀“https://”(www.mydomain.com。)的网站。
如果我不使用https://使用URL,它会在浏览器(Safari,firefox)上给我提供“无法连接到服务器”的错误,并在命令提示符处使用curl:
Rebuilt URL to: www.my-domain.com/ Trying 2xx.xxx.xxx.xxx... connect to 2xx.xxx.xxx.xxx port 80 failed: Connection refused
我根据apache文档configuration了虚拟主机,将没有 “https”的任何请求redirect到“https”。 Hier是我的configuration:
<VirtualHost 2xx.xxx.xxx.xxx:80> ServerName my-domain.com ServerAlias www.my-domain.com RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule (.*) https://my-domain.com [R,L] </VirtualHost>
有什么我缺less的configuration? 为什么Apache服务器不redirect请求? 任何帮助将不胜感激。
PS。 一旦我用https://从外部调用页面,即使删除了现金,也可以调用它,而不用使用前缀https://。 在VPN或在同一个networking,它的工作没有前缀。
你需要确保你的apacheconfiguration中有一个有效的Listen端口80。 只需添加一个端口80的虚拟主机是不够的。