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'm running an OpenVPN AS server on a VPS and the server itself has a web interface accessible through HTTPS. I'd like to redirect all HTTP traffic to HTTPS without having to install a web server for just that purpose.

Is there any simple way to redirect HTTP traffic to HTTPS?

share|improve this question
1  
You need something to tell the web browser to redirect to the HTTPS address, otherwise you'll end up with non-encrypted traffic on a port that expects encrypted traffic. Basically, you can do it, but it won't work. –  gparent Mar 17 '13 at 21:06
add comment

1 Answer

up vote 0 down vote accepted

You need something to listen on the TCP/80 port and to respond with an HTTP header containing "Location:". That's the only way a web browser will understand, and do what you want. That is, by definition, a web server. Granted, you need this web server to do very very little.

I would look at Netcat.

You could write a dead simple shell script, (or lang of your choosing,) which simply printed the Location: HTTP header, (and whatever other headers are needed,) regardless of whatever it receives as a request. Then Netcat can be used to make a TCP/80 listener wrapped around your shell script.

share|improve this answer
    
Great answer. I ended up just installing nginx, but this would be something I can look into in the future. Thanks :). –  Brad Mar 17 '13 at 21:59
add comment

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.