我需要将端口8080重定向到Linux服务器上的端口80。
我的问题是一样的:
https://askubuntu.com/a/579540

唯一的区别是我没有iptables-使用firewalld可以做到这一点吗?

编辑:现在我知道firewalld使用iptables,并且可以使用以下命令通过firewalld将命令传递给iptables:

firewall-cmd [--permanent] --direct --add-rule { ipv4 | ipv6 | eb } <table> <chain> <priority> <args>


我有:


在端口8080上运行的HTTP服务器
端口80重定向到Firewalld中的8080(区域公共)
来自其他通过端口80访问的计算机的客户端可以访问HTTP服务器
我可以从运行服务器的同一台计算机上的端口8080上访问服务器


我也要:


从运行服务器的同一台计算机访问端口80上的服务器


我试过了:


将接口“ lo”添加到区域“ public”
以与“公共”区域相同的方式配置“受信任”区域


区域“公共”配置:

<zone>
  <short>Public</short>
  <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="snmp"/>
  <service name="http"/>
  <service name="ssh"/>
  <service name="https"/>
  <icmp-block name="redirect"/>
  <icmp-block name="router-solicitation"/>
  <icmp-block name="parameter-problem"/>
  <icmp-block name="router-advertisement"/>
  <forward-port to-port="8080" protocol="tcp" port="80"/>
</zone>


错误:

#wget "192.168.100.42:80"
--2016-12-01 16:02:29--  http://192.168.100.42/
Connecting to 192.168.100.42:80... failed: Connection refused.

#wget "192.168.100.42:8080"
--2016-12-01 16:06:37--  http://192.168.100.42:8080/
Connecting to 192.168.100.42:8080... connected.
HTTP request sent, awaiting response... 302 Found
...
HTTP request sent, awaiting response... 302 Found
...
HTTP request sent, awaiting response... 302 Found
...
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’
...
2016-12-01 16:06:37 (69.8 MB/s) - ‘index.html’ saved [4785]

#wget "localhost:80"
--2016-12-01 16:02:12--  http://localhost/
Resolving localhost (localhost)... 127.0.0.1, ::1
Connecting to localhost (localhost)|127.0.0.1|:80... failed: Connection refused.
Connecting to localhost (localhost)|::1|:80... failed: Network is unreachable.

#wget "localhost:8080"
--2016-12-01 16:06:29--  http://localhost:8080/
Resolving localhost (localhost)... 127.0.0.1, ::1
Connecting to localhost (localhost)|127.0.0.1|:8080... failed: Connection refused.
Connecting to localhost (localhost)|::1|:8080... failed: Network is unreachable.


编辑:解决方案:
服务器根本没有监听回送接口。

最佳答案

服务器未在回送接口上侦听。

关于linux - 防火墙:将端口80重定向到8080,并使其在本地计算机上工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40913862/

10-13 05:31