【问题标题】:iptables port forwarding to webserver thru vpn connection without installing nginx通过 vpn 连接将 iptables 端口转发到网络服务器,无需安装 nginx
【发布时间】:2015-12-08 02:11:29
【问题描述】:

我想知道这是否可能,因为在未安装 webserver 服务时我似乎无法进行端口 80 转发。

例如,这是我的用户或机器连接的 vpn 服务器:

ppp0      Link encap:Point-to-Point Protocol  
          inet addr:192.168.1.1  P-t-P:192.168.1.2  Mask:255.255.255.255

我想将所有网络(端口 80)转发到此连接,因为网站位于用户的计算机上。

我已经使用 nginx 代理传递到 192.168.1.2 并且它有效。我想知道是否可以在不安装 nginx 的情况下使用 iptables。

谢谢。

【问题讨论】:

    标签: linux nginx iptables portforwarding forwarding


    【解决方案1】:

    解决了。

    编辑用户机器上的/etc/ppp/ip-up.d/somefile并添加:

    $someserver=192.168.0.123
    iptables -A PREROUTING -t nat -p tcp -i $1 -m multiport --dports 80,443 -j DNAT  --to $someserver
    

    在 vpn 服务器上:

    iptables -t nat -A  PREROUTING -p tcp  -m multiport --dports 80,443 -j DNAT --to 192.168.1.2
    

    【讨论】:

      猜你喜欢
      • 2010-12-06
      • 2013-06-27
      • 2021-03-27
      • 1970-01-01
      • 2021-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多