Disable port 80 and leave only 443


I used Certbot to create certification. Great tool.

It asked me if i want to leave HTTP/HTTPS open or only HTTPS, i choose to leave both open (aka port 80, 443).

Now i want to disable port 80 for and leave only port 443 open…

Do i need to configure something with Certbot?
I tried to remove from my site .conf file with the port 80 virtualhost configuration, but still site is accessed with port 80.

Help is appreciated !

The “only HTTPS” option in certbot just puts a redirect in place. You’ll probably want to have port 80 open for people who enter your domain name manually. (Most people don’t put https:// in front of every host in their address bar ;))

I added the “HTTPS” only to a specific sub domain, site it self is only port 80.
Used the command: certbot --apache -d sub.domain.com
I need the subdomain to be only HTTPS and not Both.

How do i add the redirect ?

This is the code generated by certbot in the <VirtualHost> directive corresponding to port 80:

RewriteEngine on
RewriteCond %{SERVER_NAME} =sub.domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

Of course you’ll need to change “sub.domain.com” in the above piece of code, the rest you can leave the same.

1 Like


Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.