Solved

Https hostnames

Posted on 2006-07-20
5
285 Views
Last Modified: 2010-03-04
Hi.
I have one public ip, that I want to have multiple subdomains.
The subdomains will use one wildcard certification, that will cover theme all.
Problem is that when using https, we can only have one virtual host on each ip:443.
so how would one have apache presenting visitors different data according to witch hostname is used?
test1.mydomain.com -> /var/www/test1
test2.mydomain.com -> /var/www/test2
If the solution is to set up a redirection, I want it to be transparent to the user.
0
Comment
Question by:thor918
  • 3
5 Comments
 
LVL 13

Expert Comment

by:rhickmott
ID: 17147787
Unfortunatly this is a bit like a chicken and egg scenrio as the SSL session is setup and established before the headers are sent so until the SSL connection is established the headers and more importantly the "host" field are not sent so its not possible to have name based SSL virtualhosts.

You can have IP based onses so you can assign two IPs to your server and have site1. running off one IP and site2. running off another but you will need two public IP addresses to get them both working properly.

The only way you could maybe do it is with mod_rewrites but the certificate will only be valid on one host test1. or test2. the other would complain about the certificate not being valid for the site.
0
 
LVL 2

Author Comment

by:thor918
ID: 17147879
I'm using wildcard certificate.
this means it's valid for the whole domain, including all subdomains.
0
 
LVL 2

Author Comment

by:thor918
ID: 17149031
As you probably see, I have read up on the topic before I asked. so I know that it is difficult, but I belive it should be possible to have some sort of redirect.
I got a php redirect right now, that works ok.
but I would like to see it redirect transparent. I think I read somewhere before that it is possible to redirect content transparent from the user.

I also tried something that worked pretty good, but was broken in one case I had to use a webdav service.
I used a apacheproxy to redirect output from http://localhost. and let the normal virtualhostname be taken care of there.
That worket perfect, exept that webdav refused to stay in https.

so I would be very happy if I could make a simple htaccess script that redirects content from another folder located on the same server (and the redirect is transparent from the visitor.).
0
 
LVL 27

Accepted Solution

by:
caterham_www earned 500 total points
ID: 17149556
>>Problem is that when using https, we can only have one virtual host on each ip:443.
so how would one have apache presenting visitors different data according to witch hostname is used?
test1.mydomain.com -> /var/www/test1
test2.mydomain.com -> /var/www/test2<<

How does your DocumentRoot directive look like? I'm assuming /var/www

Inside of your <virtualhost> with the module mod_rewrite loadded

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com
RewriteRule ^/(.*) /%1 [PT]
0
 
LVL 2

Author Comment

by:thor918
ID: 17149682
@caterham_www
I did't get what you posted working, but you helped me on the right path
here is what I ended up with. it works perfect.

            RewriteEngine On
            RewriteCond %{HTTP_HOST} ^websvn\.mydomain\.net$ [NC]
            RewriteRule ^(.*)$ /websvn/$1 [L]

            RewriteCond %{HTTP_HOST} ^svn\.mydomain\.net$ [NC]
            RewriteRule ^(.*)$ /mysvn/$1 [L]
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP temp path missing 4 51
Use of SSL Certificates - http vs https 3 75
htaccess file 3 78
How to ensure a smooth transition to Let's Encrypt SSL Cert? 2 70
If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now