Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I was wondering if there is any way with Windows Server 2008 DNS to forward requests for a domain using HTTP to the same domain on HTTPS? Frankly I have a feeling it is actually down to the web server but I thought I would start with the DNS system, no amount of googling is helping. Basically I want to allow a user accessing a subdomain to be automatically forwarded to the HTTPS version as I have disabled listening on port 80 for that site (the webmail system was conflicting with my web server)

Please ask if anything is unclear or I have explained it poorly.

Edit: Thinking it through it is clearly nothing to do with DNS (The clue being in the name ;) ) Does anyone knows about how to configure this with Apache (I assume this is where the answer lies)

share|improve this question

2 Answers 2

up vote 3 down vote accepted

No, DNS just maps the hostname part of a URL to an IP-address.

URL such as

http://www.example.com/path/whatever
https://www.example.com/path/whatever

Both contain the same hostname www.example.com which is the only part that is referred to DNS. Your browser looks at the protocol part (http or https) to decide what protocol it should use to contact that host.

To force a HTTP connection to be changed to an HTTPS connection you should configure the web-server to listen on the port specified in the URL and reply with a suitable redirect response if the protocol is HTTP. There are lots of ways of doing that - check the Apache manual or ask.

If there's nothing (or worse, a dedicated webmail server?) listening on the port specified in the URL you need to either get everyone to use a new URL or rethink your solution to the conflict with webmail.

Best to move webmail to another port and het Apache to redirect relevant URLs to the webmail service.

share|improve this answer
    
Hi, Thanks for the reply. I was editing your question as you posted this :) Think I had a blank on DNS for a moment. I will re-try googling again to see if I can find a better answer –  Draineh Apr 21 '11 at 14:44

Basically I want to allow a user accessing a subdomain to be automatically forwarded to the HTTPS version as I have disabled listening on port 80 for that site (the webmail system was conflicting with my web server)

As it sounds like you have a different service daemon listening on port 80, you won't be able to do this with your current setup. Any http request will go straight to port 80 on your machine (which you have disabled). You'll need to reenable Apache to listen on port 80 and rewrite URLs as the user sends a request to your http:// host.

The standard Apache way of doing this would be with mod_rewrite and doing something like this:

<VirtualHost *:80>
  RewriteEngine on
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

See http://httpd.apache.org/docs/current/mod/mod_rewrite.html for more documentation.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.