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:
ServerAdmin support@example.com
DocumentRoot /var/www/mysslwebsite
ServerName www.mysslwebsite.com
ServerAlias mysslwebsite.com
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Options FollowSymLinks
AllowOverride all
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
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
ServerAdmin support@email.com
DocumentRoot /var/www/mysslsite
ServerName www.mysslsiste.com
ServerAlias mysslsite.com
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Options FollowSymLinks
AllowOverride all
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
ServerAdmin support@email.com
DocumentRoot /var/www/mysslsist
ServerName www.mysslsist.com
ServerAlias mysslsist.com
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Options FollowSymLinks
AllowOverride all
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
#Another virtual host with another site
ServerAdmin support@email.com
DocumentRoot /var/www/myothersite
ServerName www.myothersite.com
ServerAlias myothersite.com
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Options FollowSymLinks
AllowOverride all
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
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.
Answer
It looks to me that you are not specifying a 443 port or a 80 port for the virtual host. So everything is heading towards the virtual host which is configured for SSL. So http traffic is not being accepted as it is configured to only accept SSL. Try this
NameVirtualHost *:80
ServerName blah
DocumentRoot /var/www/html/
...
- your config here -
...
You could even do a redirect for the virtual host running on port 80. Maybe something like this:
Redirect permanent / https://
No comments:
Post a Comment