zoukankan      html  css  js  c++  java
  • 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


    本文参考:http://www.cnblogs.com/chenmo-xpw/p/5519593.html,感谢该博主分享!
    
    
    
  • 相关阅读:
    bzoj3196 Tyvj 1730 二逼平衡树
    bzoj2929 [Poi1999]洞穴攀行
    bzoj2325 [ZJOI2011]道馆之战
    cf413E Maze 2D
    bzoj2599 [IOI2011]Race
    bzoj1528 [POI2005]sam-Toy Cars
    UVA 796 Critical Links(无向图求桥)
    UVA 315 Network(无向图求割点)
    HDU 1269 迷宫城堡(求是否只有一个强连通分量)
    HDU 3974 Assign the task
  • 原文地址:https://www.cnblogs.com/lixiuming521125/p/6295658.html
Copyright © 2011-2022 走看看