title: Firewalld: Redirect port 80 to 8080 and make it work on local machine
body: <p>I need to redirect port 8080 to port 80 on my linux server.
  My problem is the same as:
  <a href="https://askubuntu.com/a/579540">https://askubuntu.com/a/579540</a></p>
  
  <p>The only difference is that I don't have iptables - is there a way of doing this with firewalld?</p>
  
  <p>EDIT: Now I know that firewalld uses iptables and commands can be passed to iptables via firewalld using:</p>
  
  <pre><code>firewall-cmd [--permanent] --direct --add-rule { ipv4 | ipv6 | eb } &lt;table&gt; &lt;chain&gt; &lt;priority&gt; &lt;args&gt;
  </code></pre>
  
  <p><strong>I have:</strong></p>
  
  <ul>
  <li>HTTP server running on port 8080</li>
  <li>port 80 redirected to 8080 in firewalld (zone public)</li>
  <li>clients from other computers accessing through port 80 can get to the HTTP server</li>
  <li>I can access the server on port 8080 from the same computer, where the server is running</li>
  </ul>
  
  <p><strong>I want also:</strong></p>
  
  <ul>
  <li>accessing the server on port 80 from the same computer, where the server is running</li>
  </ul>
  
  <p><strong>I tried:</strong></p>
  
  <ul>
  <li>adding interface "lo" to zone "public"</li>
  <li>configuring zone "trusted" in the same way as zone "public"</li>
  </ul>
  
  <p><strong>Zone "public" configuration:</strong></p>
  
  <pre><code>&lt;zone&gt;
    &lt;short&gt;Public&lt;/short&gt;
    &lt;description&gt;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.&lt;/description&gt;
    &lt;service name="snmp"/&gt;
    &lt;service name="http"/&gt;
    &lt;service name="ssh"/&gt;
    &lt;service name="https"/&gt;
    &lt;icmp-block name="redirect"/&gt;
    &lt;icmp-block name="router-solicitation"/&gt;
    &lt;icmp-block name="parameter-problem"/&gt;
    &lt;icmp-block name="router-advertisement"/&gt;
    &lt;forward-port to-port="8080" protocol="tcp" port="80"/&gt;
  &lt;/zone&gt;
  </code></pre>
  
  <p><strong>Errors:</strong></p>
  
  <pre><code>#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.
  </code></pre>
  
  <p><strong>EDIT: SOLUTION:</strong>
  The server was not listening on loopback interface at all.</p>