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 have an apache server v2.2, with a virtual host on 80 and another with SSL on 444. I would like to redirect all this kind of request:

http://domain.tld:444/dir1
http://domain.tld:444/dir2

(without https on SSL port) to

https://domain.tld:444/dir1
https://domain.tld:444/dir2

In order to avoid error 400 Bad request. Do you know how it can be done ?

Thanks in advance.

share|improve this question

3 Answers 3

You can't do that. If you have enabled SSL on port 444, a connection without SSL to that port simply will not work.

share|improve this answer

Apache cannot do this directly. When it listens on a port, it is listening for either plain HTTP traffic or HTTPS traffic and the other type of connection will just fail.

A clever application, however, can try to inspect the initial connection data, decide what sort of connection is being attempted, and take appropriate action. sslh does this. To use it, you will have to set up two Apache virtual hosts , each listening on a different port on the localhost address. With those in place, you would have sslh listen on port 444 and forward HTTP and HTTPS traffic to the appropriate internal ports.

share|improve this answer

Just set your configuration to use redirect of mod_alias:

<VirtualHost *:80>
    ServerName www.example.com
    Redirect permanent / https://www.example.com/
</VirtualHost >

Source: mod_alias#redirect

share|improve this answer
1  
I don't think that helps John. He appears to want to be able to accept HTTP and HTTPS traffic on the same port. Your solution only accepts HTTP on port 80 and HTTPS on port 443. –  asciiphil Jun 3 '13 at 17:38
    
I can confirm. I dont want to accept both request's type, but at least redirect HTTP to HTTPS. It seems that asciiphil's solution is the best way... –  John Jun 4 '13 at 10:38

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.