dongle2627 2018-08-15 20:22
浏览 80

如何将数据从默认端口路由到另一个端口[4001]

currently my go server is running on port 4001 for https request. to access web application i need to type domainname:4001 in browser.

I would like only to type domainname ato make the connection to web server on port 40001.

  • 写回答

1条回答 默认 最新

  • doutan5337 2018-08-15 20:52
    关注

    You may either use iptables or modify your program to listen on :80 (HTTP) or :443 (HTTPS).

    With iptables, these commands will redirect all :80 and :443 traffic on your server to :8080 and :8443 respectively, internally.

    sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080 sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443

    You may need to install iptables. Run sudo apt install iptables.

    This is a temporal fix. To make it permanent, put those lines in your ~/.bashrc

    If you don't want to use iptables, then modify the ports your program is listening on. However, remember that ports under 1024 need root permissions, so you'll need to run the program as root.

    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路