0

I have a site example.com and setup a VirtualHost to redirect to https://www.example.com

When I go to http://example.com it works great, however https does not

How can I update my VirtualHost configuration to also direct https traffic?

<VirtualHost *:80>
  ServerName example.com
  Redirect permanent "/" "https://www.example.com"
</VirtualHost>

<VirtualHost *:443>
  ServerName example.com
  Redirect permanent "/" "https://www.example.com"
</VirtualHost>

The top one works great and redirects as expected, but https://example.com does not

Confirmed in AWS that the instance allows all traffic on both ports 80 and 443

--update

This is hosted on an AWS EC2 instance, and the HTTPS certificate in question was issued via the AWS Certificate Manager. Per Shim's suggestion I looked at https://wiki.apache.org/httpd/NameBasedSSLVHosts but it requires me to export a certificate which AWS does not permit? Is there another way around this?

Joshua Ohana
  • 5,613
  • 12
  • 56
  • 112
  • Try to read the documentation here : https://wiki.apache.org/httpd/NameBasedSSLVHosts . You have to enable mod_ssl and create certificates for your domains. – Shim-Sao Dec 02 '18 at 01:43
  • Thanks Shim, I have an SSL and wildcard certificate already. Will try to follow this guide. – Joshua Ohana Dec 02 '18 at 01:57
  • @Shim-Sao Please see my update if you have a moment. The server is hosted on AWS EC2 and its sole purpose is a direct. With the certificate in AWS, how can I perform this https redirect? – Joshua Ohana Dec 02 '18 at 02:20
  • @Prix The official guide suggests using a self-signed (which gives the user an error) or one from a CA. Unfortunately, we're using an AWS ACM certificate which you cannot export the public one. – Joshua Ohana Dec 02 '18 at 02:38
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/184572/discussion-between-joshua-ohana-and-prix). – Joshua Ohana Dec 02 '18 at 03:04
  • Unfortunately that's only for private certificates not public – Joshua Ohana Dec 02 '18 at 03:21
  • Maybe this discussion can help you : https://stackoverflow.com/questions/34945299/how-to-add-ssl-certificate-to-aws-ec2-with-the-help-of-new-aws-certificate-manag . It seems that what you are doing is not allowed. – Shim-Sao Dec 02 '18 at 10:49
  • I also found this : https://aws.amazon.com/fr/premiumsupport/knowledge-center/connect-http-https-ec2/ – Shim-Sao Dec 02 '18 at 11:32
  • Here is a tutorial to install free ssl on AWS EC2 : https://hackernoon.com/getting-a-free-ssl-certificate-on-aws-a-how-to-guide-6ef29e576d22 – Shim-Sao Dec 02 '18 at 11:34
  • Thanks those were all workarounds to avoid using the way I had it existing setup. I ended up resolving the need for this workaround in the first place so no longer need this. – Joshua Ohana Dec 02 '18 at 18:29

0 Answers0