共計 1126 個字符,預計需要花費 3 分鐘才能閱讀完成。
這篇文章主要講解了“mac os 80 端口怎么間接使用”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著丸趣 TV 小編的思路慢慢深入,一起來研究和學習“mac os 80 端口怎么間接使用”吧!
資料顯示 MAC OS 本質是 Unix 系統,默認非 root 用戶無法使用 1024 一下的端口,要是非要用,比如一般情況下,本地項目用 tomcat 運行,一般都是 localhost:8080/XXXX, 如果想通過 localhost/XXXf 方式來訪問, 可以通過間接的方式來使用 80 端口;
1. 打開終端,
2. 創建文件 :
sudo vim /etc/pf.anchors/eclipse.tomcat.forwarding
3. 輸入文件內容:
rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 80 - 127.0.0.1 port 8080
rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 443 - 127.0.0.1 port 8443
4:保存并退出,按住 ESC,輸入:wq
5. 創建文件 :
sudo vim /etc/pf-tomcat.conf
6. 輸入文件內容
rdr-anchor forwarding
load anchor forwarding from /etc/pf.anchors/eclipse.tomcat.forwarding
7. 保存并退出,按住 ESC,輸入:wq
8. 啟動
sudo pfctl -ef /etc/pf-tomcat.conf
執行結果如下就可以通過 80 端口來訪問了
root@ymdeMacBook-Air etc# sudo pfctl -ef /etc/pf-tomcat.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.
No ALTQ support in kernel
ALTQ related functions disabled
pf enabled
想要關閉的話,命令是
sudo pfctl -d
全部關閉的命令
pfctl -F all -f /etc/pf.conf
感謝各位的閱讀,以上就是“mac os 80 端口怎么間接使用”的內容了,經過本文的學習后,相信大家對 mac os 80 端口怎么間接使用這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是丸趣 TV,丸趣 TV 小編將為大家推送更多相關知識點的文章,歡迎關注!