Is there a way to redirect all website requests that come to my server from port 80 to port 443 without needing Apache to listen on port 80? Thus freeing port 80 for other use. I'm thinking like some sort of local proxy that detects if the incoming request is for a site and if so, just point it at the https site on port 443. If not, let it stroll on through to whatever else is running on port 80. Thanks.

  • Well, you can run a different httpd (nginx, etc) on that port that redirects to apache on port 443. However, that blocks the port again and gains you nothing. – Gerald Schneider Jul 31 '18 at 13:34
  • 1
    What "other use" are you looking to use port 80 for? – ceejayoz Jul 31 '18 at 13:44
  • @ceejayoz a mix of OpenVPN and Stunnel. – Benji Collins Jul 31 '18 at 13:53

What you are looking for, seems to me, is a Protocol Multiplexer and what I could find useful to try with is sslh:


It's very easy to install and configure, and can detect certain applications by analyzing first data packet and can perform port forwarding.

Check the following link for an example:


I haven't tested it myself and also won't recommend something like this for an productive environment though.


You need something on the port 80 which understand plain HTTP, otherwise the browser which connects there just will be refused or ignored (depends on your firewall).

You have to configure your Apache to listen on port 80 as well, and redirect all the request come to this port (eg: having different VirtualHosts on port 80 and port 443)

You can use the rewrite module for your HTTP request on port 80:

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://your.server.com%{REQUEST_URI} 

This redirects all the request to the same URL, but with https:// (and optionally to another server).E.g.:

http://your.server.com/foo/bar -> https://your.server.com/foo/bar

If you want save the port 80 for other usage you can fine tune the rewrite rule to rewrite only certain requests and serve the rest or rewrite the rest to another service. But obviously you have to decide what listens on the port 80, Apache or another service.

See more in the Apache mod_rewire documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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