How to close a port on the network

2

I ran an nmap scan on my (Ubuntu) computer on the local network and each time I found that port 80 is open. It's used by Apache. I changed the security options so Apache will no longer respond to any access request from the LAN, but is there any way to close it so it doesn't appear in case of scan without killing the Apache service?

P.S.: I tried ufw deny 80 but it didn't work for me.

Barttttt

Posted 2018-06-09T16:44:04.800

Reputation: 27

here the lan is just the example, it can be the wifi too, sometimes I used wifi in cafes, restaurant, public wifis ..... while working with on laptop. the port was opened by default when I installed apache for local dev and I've no intention to use it as a webserver. – Barttttt – 2018-06-09T19:56:37.787

what do you mean by the "Host", I scanned my pc which is an ubuntu machine looking for the opened port! – Barttttt – 2018-06-09T20:16:01.487

There we go. Ubuntu is what I was looking for. It's vital info for an adequate answer guy. :) Appache runs on pretty much everything – Tim_Stewart – 2018-06-09T20:18:07.070

Sorry for that, when I posted the question I forgot that SuperUser could be windows Admins, which led to this confusion. – Barttttt – 2018-06-09T22:37:24.633

Did you try in appache to put the service on 127.0.0.1:80 ? It should make it still available to the host OS but not serve port 80 on the lan or WLAN adapter. – Tim_Stewart – 2018-06-09T23:09:37.077

how to do it please? – Barttttt – 2018-06-10T18:03:55.950

Answers

1

in your site-enabled list.

<Location "/">.
order Deny,allow.
Deny from all.
allow from 127.0.0.0/255.0.0.0 ::1/128.
</Location>

This should limit Apache from serving to the localhost only.

Or

Change ports.conf so that it contains: Listen 127.0.0.1:80 only.

https://help.ubuntu.com/community/ApacheMySQLPHP#Securing%20Apache

Tim_Stewart

Posted 2018-06-09T16:44:04.800

Reputation: 3 983

Thank you! you are so helpful! the last one work for me! and now I can use apache on my machine as a dev server and prevent it from listening for incoming connection attempts. – Barttttt – 2018-06-10T20:19:29.547

cool, glad I could help! – Tim_Stewart – 2018-06-10T20:34:50.100