Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-19-2011, 11:50 AM   PM User | #1
pete.robinson
New to the CF scene

 
Join Date: Aug 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
pete.robinson is an unknown quantity at this point
Wildcard SSL Woes

Hi Guys,
So I've recently bought and installed a wildcard SSL on my server which governs domain.com and any subdomain that I add to it.

In essence, the cert works fine. For example, if I set up a static 'hello world' PHP page and set the domain to sub1.domain.com, the page is displayed in both HTTP and HTTPS (with some mod_rewrite which I'll come to shortly).

The issue is that the domain is serving applications, which all kind of need their own document root to function properly.

If I print_r the $_SERVER array outside HTTPS, I see the correct document root - something like:
/home/domain.com/public_html/_apps/sub1/
That would be the doc root for sub1.domain.com

If I then switch over to HTTPS and again, print_r the $_SERVER array, I get:
/home/domain.com/public_html

It seems to be completely ignoring the docroot for that subdomain. The current mod_rewrite I'm using in the docroot of the base domain is:

Code:
RewriteEngine On
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} ^sub1\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/_apps/sub1/
RewriteRule ^(.*) /_apps/sub1/$1
This is required to get the wildcard SSL working across multiple subdomains. Without this, switching to SSL just reverts to the base domain.

Does anybody know if/how I can maintain the document root from normal HTTP inside HTTPS and stop it changing the document root to that of the base domain when running through HTTPS?

Cheers
Pete
pete.robinson is offline   Reply With Quote
Old 08-19-2011, 08:57 PM   PM User | #2
Cags
New Coder

 
Join Date: Jul 2011
Posts: 67
Thanks: 0
Thanked 13 Times in 13 Posts
Cags is an unknown quantity at this point
Hey Pete,

What does your VirtualHost setup look like, do you just have the one default Virtual host that is catching all requests?
Cags is offline   Reply With Quote
Old 08-22-2011, 09:44 AM   PM User | #3
pete.robinson
New to the CF scene

 
Join Date: Aug 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
pete.robinson is an unknown quantity at this point
Quote:
Originally Posted by Cags View Post
Hey Pete,

What does your VirtualHost setup look like, do you just have the one default Virtual host that is catching all requests?
Hi Cags,
My VirtualHost setup looks like this:
Code:
<VirtualHost XXX.XXX.XXX.XXX:80>
    ServerName sub1.domain.com
    ServerAlias www.sub1.domain.com
    DocumentRoot /home/domain/public_html/_apps/sub1/public_html
    ServerAdmin webmaster@sub1.domain.com
    UseCanonicalName On
    CustomLog /usr/local/apache/domlogs/sub1.domain.com combined
    CustomLog /usr/local/apache/domlogs/sub1.domain.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User wunderap # Needed for Cpanel::ApacheConf
    <IfModule !mod_disable_suexec.c>
        SuexecUserGroup wunderap wunderap
    </IfModule>
    ScriptAlias /cgi-bin/ /home/domain/public_html/_apps/sub1/public_html/cgi-bin/
</VirtualHost>
No, there is one virtualhost entry for each subdomain.

Thanks
Pete
pete.robinson is offline   Reply With Quote
Old 08-22-2011, 09:49 AM   PM User | #4
Cags
New Coder

 
Join Date: Jul 2011
Posts: 67
Thanks: 0
Thanked 13 Times in 13 Posts
Cags is an unknown quantity at this point
It might be worth taking a look at this...

http://wiki.apache.org/httpd/NameBasedSSLVHosts
Cags is offline   Reply With Quote
Reply

Bookmarks

Tags
apache, conf, mod_rewrite, ssl, subdomains

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:38 AM.


Advertisement
Log in to turn off these ads.