Mobile app version of vmapp.org
Login or Join
Michele947

: Changing port from 80 to 443 redirects site to index (SSL) My setup: Apache 2.4.7 Ubuntu 14.04 w/wordpress Host: DigitalOcean I have figured out what is causing the redirect but I cannot figure

@Michele947

Posted in: #Https #Openssl #SecurityCertificate

My setup:


Apache 2.4.7
Ubuntu 14.04 w/wordpress
Host: DigitalOcean


I have figured out what is causing the redirect but I cannot figure out why or how to fix it.

When changing the port from 80 to 443 in 000-default.conf it directs the site to the index, when put back to 80 the site loads properly but without SSL.

Here is the code of my 000-default.conf

<VirtualHost *:443>
ServerName prollagen.com
SSLEngine on
SSLCertificateFile /etc/ssl/.crt
SSLCertificateKeyFile /etc/ssl/.key
SSLCertificateChainFile /etc/ssl/.crt
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Michele947

1 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

You don't want to put your configuration into 000-default.conf. That file is overwritten when Apache is upgraded. Instead you should put your configuration into /etc/apache2/sites-available/prollagen.conf. Put the default conf file back to how it was. You will need two virtual host directives. One for HTTPS and one for HTTP. I assume that you want HTTP to redirect to HTTPS.

<VirtualHost *:80>
ServerName prollagen.com
Redirect permanent / prollagen.com/ </VirtualHost>

<VirtualHost *:443>
ServerName prollagen.com
SSLEngine on
SSLCertificateFile /etc/ssl/.crt
SSLCertificateKeyFile /etc/ssl/.key
SSLCertificateChainFile /etc/ssl/.crt
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


Once this new file is in place enable it and restart the server:

sudo a2ensite prollagen && sudo service apache2 restart

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme