我目前正在测试我的开发环境是否可以在即将发布的新Mac OS 10.11上运行,并且如果可以,我会尽快升级。在我的测试机器上,我目前正在运行Beta Preview 3,一切似乎都运行正常。
我不能让pfctl
转发我的端口。我使用Vagrant和Parallels Desktop来运行Debian系统作为我的本地Web服务器。 Vagrant将主机上的端口8080转发到客户机上的端口80。因此,127.0.0.1:8080
可以正常工作。但在某些项目中,我希望本地域与生产环境中的完全相同(没有:8080)。此外,我更喜欢这种方式。 ;-)
为了做到这一点,我使用pfctl
将80转发到主机上的8080。以下是我的配置文件:
〜/ port-forwarding / pf.conf
rdr-anchor "forwarding"
load anchor "forwarding" from "/Users/nick/port-forwarding/rules.conf"
~/端口转发/规则.conf
rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass on lo0 inet proto tcp from any to any port 443 -> 127.0.0.1 port 4433
为了启用它,我运行:
sudo pfctl -vnf ~/port-forwarding/pf.conf
sudo pfctl -evf ~/port-forwarding/pf.conf
这给了我这个:
pfctl: Use of -f option, could result in flushing of rules
present in the main ruleset added by the system at startup.
See /etc/pf.conf for further details.
rdr-anchor "forwarding" all
Loading anchor forwarding from /Users/nick/port-forwarding/rules.conf
rdr pass on lo0 inet proto tcp from any to any port = 80 -> 127.0.0.1 port 8080
rdr pass on lo0 inet proto tcp from any to any port = 443 -> 127.0.0.1 port 4433
pfctl: Use of -f option, could result in flushing of rules
present in the main ruleset added by the system at startup.
See /etc/pf.conf for further details.
No ALTQ support in kernel
ALTQ related functions disabled
rdr-anchor "forwarding" all
Loading anchor forwarding from /Users/nick/port-forwarding/rules.conf
rdr pass on lo0 inet proto tcp from any to any port = 80 -> 127.0.0.1 port 8080
rdr pass on lo0 inet proto tcp from any to any port = 443 -> 127.0.0.1 port 4433
pf enabled
logout
Saving session...completed.
No ALTQ support in kernel
ALTQ related functions disabled
rdr-anchor "forwarding" all
目前看起来还不错。但它就是不工作。
127.0.0.1:80
- 没有连接。
127.0.0.1:8080
- 可以工作。
我在 Yosemite 上使用相同的文件,那里工作得很好。
是否有人知道如何使用 pfctl
发生了变化,或者我是否做错了什么,或者是否有一个可以报告的错误。
非常感谢
Nick