I am trying to use pf
firewall on macos Catalina 10.15.3 to allow www (80,443) access for a specific local IP address on my home network. This local IP address will request web pages from a nginx instance. If I turn off the macos firewall in settings=>Security & Privacy then the www is successful and the nginx is displayed. However, I cannot get the request through for the specific IP address when the firewall is enabled. Initially my nginx setup listens on port 80 and 443.
Following this I tried investigating how to configure the pf
firewall to allow the request through for a specific IP address. My /etc/pf.conf is currently as follows:
#
# com.apple anchor point
#
scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
rdr-anchor "com.apple/*"
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
#
# only allow www traffic on wifi interface from a specific LAN ip address
#
www_services = "{ http, https }"
pass quick inet proto tcp from <the LAN IP address> to any port $www_services keep state
#int_if = "en0"
#table <allowed> { <the LAN IP address> } persist
#block in quick from urpf-failed
#block return in quick on $int_if proto tcp from !<allowed> to $int_if port 80
Can anyone help?
I am enabling pf firewall using pfctl -E
and disabling with pfctl -X <token>
Interestingly, if I configure nginx to listen on a different port other than port 80 and then add nginx to the list of allowed applications in the Security & Privacy firewall, the request is allowed through.
However, I suspect this is allowed through for all IP addresses on the LAN and all ports nginx listens to?? I am trying to configure the Packet filter firewall (pf) so that the IP address and port is restricted. Maybe port 80 is root reserved ports hence the reason why it was blocked???
How do I get pf firewall to only allow a specific IP address through for a http request on a specific port, e.g. 8080?