博主分享免费Java教学视频,B站账号:Java刘哥
- [ ] 方案一: Mac OS X 因为要绑定80端口需要ROOT权限, 但是如果用root权限启动eclipse或tomcat又会造成, 启动创建的各类文件是root的,普通用户无法删除,放弃。
- [x] 方案二: 通过pfctl做网络层的端口转发, 让连接到本机80端口的请求,都转发到8080端口;采纳
一、修改/etc/pf.conf
先对pf.conf进行备份:- sudo cp /etc/pf.conf /etc/pf.conf.normal.bak
- sudo vim /etc/pf.conf
rdr-anchor "com.apple/*"
后面添加一行配置,如下:
- rdr on lo0 inet proto tcp from any to 127.0.0.1 port 80 -> 127.0.0.1 port 8080
二、依次执行以下命令:
- sudo pfctl -d
- sudo pfctl -f /etc/pf.conf
- sudo pfctl -e
注意:如果有apache等服务器占用了80端口,则需要将其停掉方能成功!
如果出现 No ALTQ support in kernel ALTQ related functions disabled pfctl: pf not enabled问题一:getsockopt: connection refused(暂时未遇到)
- 2017/08/07 18:47:52 [E] [proxy.go:332] [sell] connect to local service [127.0.0.1:80] error: dial tcp 127.0.0.1:80: getsockopt: connection refused
pfctl
转发到8080端口,当时有效,但因为重启电脑后,pfctl
的配置又变回之前了,需要配置在开机启动的配置文件中。
注:开机启动需要编辑文件 /System/Library/LaunchDaemons/com.apple.pfctl.plist
- <string>pfctl</string>
- <string>-e</string>
- <string>-f</string>
- <string>/etc/pf.conf</string>
10.11
以上系统因为增强了安全模式,导致/System/Library/LaunchDaemons/com.apple.pfctl.plist
修改失败,请重启至安全模式在进行操作。
原文地址:https://blog.csdn.net/inke88/article/details/76677911
- 微信
- 交流学习,有偿服务
- 博客/Java交流群
- 资源分享,问题解决,技术交流。群号:590480292
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏