C
C
CyMpak2010-09-13 10:46:32
Apache HTTP Server
CyMpak, 2010-09-13 10:46:32

How can I disable http access and close port 80 on Apache (Linux)?

In a situation where only SSL connections are used, I don’t think it makes much sense to keep one more port.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
J
justabaka, 2010-09-13
@CyMpak

If there is a chance that someone will forget about HTTPS and go by simply entering the site address, then out of love for users, it makes sense to redirect.
In general:
1. Edit ports in /etc/apache2/ports.conf:

#Listen 80

2. edit virtualhosts in /etc/apache2/sites-available:
<IfModule mod_ssl.c>
<VirtualHost example.com:443>
...
</VirtualHost>
</IfModule>

A
amario, 2010-09-13
@amario

# listen 80

S
Sergey, 2010-09-13
@bondbig

leave port 80 open, but make an unconditional redirect:
Redirect permanent / https://your.domain.ru/
This will be more convenient, you will not need to type https:// in front of the address.

A
ainu, 2010-09-13
@ainu

If hosting on ispmanager, then add port 8080 to the firewall/firewall section.
If not, then google iptables yourself, or something else that is on the server. This is in the case of nginx with 8080.
For all other cases, as amario rightly pointed out, # listen 80

R
R1nat, 2010-09-13
@R1nat

And in a situation where nginx hangs on port 80, and Apache on 8080, how to close the Apache port for everyone from the outside, leaving it only for nginx?

With iptables, you can do this:
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 8080 -j DROP

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question