I'm running a dedicated web server and I'd like to use APF to block HTTP(S) access to certain PORTS from all IP's except from mine.

Anyone knows how to do that?

Many thanks in advance!

I have never heard about APF until now but after reading their site:

The technical side of APF is such that it utilizes the latest stable features from the iptables (netfilter) project to provide a very robust and powerful firewall.

Is using iptables directly a solution?

Based on these instructions:


1) Login to your server as the root user.

2) cd /etc/apf

3) Use vi or nano or emacs to edit the /etc/apf/allow_hosts.rules file

e.g.: vi /etc/apf/allow_hosts.rules

4) Scroll down until after their last comment with the ##

Add the following in:


The d=443 part is the https port, so you can repeat for other services as well to limit connections if you like.

You must change YOURHOMEIPHERE to the IP address you want to let in. If this is going over the Internet you need to know your external IP address. Try http://www.ipaddressworld.com/ or some such service to see what your external IP address is.

Save the changes.

5) Edit the /etc/apf/deny_hosts.rules file
EG: vi /etc/apf/deny_hosts.rules

Scroll down until the last default comment ## then below it add the following:


Save the changes.

6) Restart APF firewall
apf -r

commented: Great help provided :) +2

Thank you sknake, but no, iptables directly was not an option.

Thank you babystrangeloop, that's it! :)