I have installed an SSL certificate on my Ubuntu EC2 instance and I need one of the websites hosted on this instance to be accessible via https.
I have several websites hosted all on the same IP through Virtual Hosts. However, I only need one website to be accessible via https.
I am sure about the following:
- SSL certificate is properly installed
- Port 443 is open on EC2
I am sure about these because when I tried the following Virtual Host configuration in the /etc/apache2/sites-enabled/mysslsite I could access the site via https. The problem was that all the other websites went down because they also required to be accessed ONLY through https. The following is the virtual host configuration file:
<VirtualHost *>
ServerAdmin support@example.com
DocumentRoot /var/www/mysslwebsite
ServerName www.mysslwebsite.com
ServerAlias mysslwebsite.com
<Directory /var/www/mysslwebsite>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
SSLEngine on
SSLCertificateFile /etc/ssl/apache2/mycertificate.com.crt
SSLCertificateKeyFile /etc/ssl/apache2/mycertificate.key
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
With this configuration, although it is located in this specific mysslwebsite virtual host config, all the other websites won't load through standard http and show the following message when accessed through http:
Bad Request
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.
Hint: https://www.myothersite.com/
Anyone knows how I can fix this?
Thank you
-------EDIT-------
I tried the following virtual hosts:
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost *:80>
ServerAdmin support@email.com
DocumentRoot /var/www/mysslsite
ServerName www.mysslsiste.com
ServerAlias mysslsite.com
<Directory /var/www/mysslsite>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
<VirtualHost *:443>
ServerAdmin support@email.com
DocumentRoot /var/www/mysslsist
ServerName www.mysslsist.com
ServerAlias mysslsist.com
<Directory /var/www/mysslsist>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
SSLEngine on
SSLCertificateFile /etc/ssl/apache2/certificate.com.crt
SSLCertificateKeyFile /etc/ssl/apache2/certificate.key
</VirtualHost>
#Another virtual host with another site
<VirtualHost *>
ServerAdmin support@email.com
DocumentRoot /var/www/myothersite
ServerName www.myothersite.com
ServerAlias myothersite.com
<Directory /var/www/myothersite>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
However, I could not access the website via SSL. I could access it via http though.
Apache showed the following warnings when restarting:
NameVirtualHost *:443 has no VirtualHosts NameVirtualHost *:80 has no VirtualHosts
This is confusing as port 80 has about 10 Virtual Hosts.