Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Jul 15, 2015 8:25 am 
Offline
Junior Member

Joined: Mon Oct 17, 2011 11:11 pm
Posts: 35
I think I fit the gist of the problem into the post title. I'm running Apache off of Ubuntu 14.01

I installed SSL on a Virtualhost previously running on port 80. The port is now running on port 443 as it should. When I enter the URL along with the HTTPS protocal into the address bar, everything works fine. But if I omit HTTPS, it redirects to another one of my virtualhosts.

I know it's a problem with the using port 443 and that Apache is rather choosing a virtualhost with port 80. Is my only option to alter the .htaccess file, or there a better way to address the issue?

Here's a pseudo mockup of my current setup under sites-enabled

Code:
<VirtualHost *:443>
  SSLEngine On
  SSLCertificateFile /path/to/cert
  SSLCertificateKeyFile /path/to/keyfile
  SSLCACertificateFile /path/to/CAcert

  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin mysite@test.com
  ServerName  www.mysite@test.com
  ServerAlias  mysite@test.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex na.html na.php
  DocumentRoot /path/to/mysite@test.com/root
</VirtualHost>


Top
   
PostPosted: Wed Jul 15, 2015 8:42 am 
Offline
Senior Newbie

Joined: Tue Apr 01, 2014 3:35 pm
Posts: 15
Virtualhosts are port-specific, if you have no virtualhost for that domain configured under port :80 it will send all traffic over http:// to your default web docroot.

Code:
<VirtualHost *:80>
   ServerName www.mysite@test.com
   ServerAlias  mysite@test.com
   Redirect permanent / https://www.mysite@test.com/
</VirtualHost>


Top
   
PostPosted: Wed Jul 15, 2015 9:44 am 
Offline
Junior Member

Joined: Mon Oct 17, 2011 11:11 pm
Posts: 35
Thanks for the reply synapt. From what I understand, you're saying I should have two virtualhosts configured for this domain, one for port 443 and the other 80 which provides the redirect using https protocal.

I'm assuming I place your example code in the same .conf file as my port 443 virtualhost. Is the below code correct?

Code:
<VirtualHost *:80>
   ServerName www.mysite@test.com
   ServerAlias  mysite@test.com
   Redirect permanent / https://www.mysite@test.com/
</VirtualHost>

<VirtualHost *:443>
  SSLEngine On
  SSLCertificateFile /path/to/cert
  SSLCertificateKeyFile /path/to/keyfile
  SSLCACertificateFile /path/to/CAcert

  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin mysite@test.com
  ServerName  www.mysite@test.com
  ServerAlias  mysite@test.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex na.html na.php
  DocumentRoot /path/to/mysite@test.com/root
</VirtualHost>


Top
   
PostPosted: Wed Jul 15, 2015 9:57 am 
Offline
Senior Newbie

Joined: Tue Apr 01, 2014 3:35 pm
Posts: 15
Indeed, looks like that should work fine.


Top
   
PostPosted: Wed Jul 15, 2015 11:20 am 
Offline
Junior Member

Joined: Mon Oct 17, 2011 11:11 pm
Posts: 35
Great I'll give it a shot this evening. Thank you for your help!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
RSS

Powered by phpBB® Forum Software © phpBB Group