Ssl – Apache – Restrict access to a specific port

apache-2.2portssl

I need to restrict access to a specific port only, on my apache server (I'd like that only the SSL port (443) is used on my webserver).
So for example, if an user try to connect to standard port 80, he would get an access denied message.
I googled for a possible solution, but I was not able to find good configuration examples.

If you need more information, don't hesitate to ask.

Best Answer

If you tell apache to simply not listen on port 80, then the user trying to get to your site will get an error message - but it will most likely make them think that your entire site is down.

Instead, I'd recommend that you set up a very simple configuration to accept incoming requests on port 80, but immediately issue a redirect to the SSL-enabled port 443. Like this:

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