Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I'm trying to port forward for my custom server. I'm using Apache for a test cos my custom built server is slightly alpha at the moment and I know ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    2

    iptables forward port 8080 to port 80


    Hi, I'm trying to port forward for my custom server. I'm using Apache for a test cos my custom built server is slightly alpha at the moment and I know apache is a stable server. I'm port forwarding port 8080 to port 80 with Apache and Iptables.

    On the Loopback interface, I can connect to port 8080 which I've forwarded to port 80, so everything works on Loopback.

    However, I have a computer in the loungeroom which is on a different ISP, and ive tried connecting to port 8080 on the server machine, it does not work. It can only connect to port 80 (and 50000 if my custom server is running).

    So it works for Loopback, but not remotely.
    Which is a bit strange because ive set up the same rules for both the lo and eth0 interfaces.


    Here are my rules -
    #!/bin/bash
    /sbin/iptables --flush
    /sbin/iptables -t nat --flush
    /sbin/iptables -t mangle --flush
    /sbin/iptables -t nat --policy OUTPUT ACCEPT
    /sbin/iptables -t nat --policy PREROUTING ACCEPT
    /sbin/iptables -t nat --policy POSTROUTING ACCEPT
    iptables -A INPUT -p tcp --dport 50000 -j ACCEPT
    iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
    iptables -A INPUT -p tcp --dport 80 -j ACCEPT

    #apache eth0
    iptables -t nat -A OUTPUT -o eth0 -p tcp --dport 8080 -j REDIRECT --to-port 80

    #apache loopback
    iptables -t nat -A OUTPUT -o lo -p tcp --dport 8080 -j REDIRECT --to-port 80





    #######my custom server stuff#########
    iptables -t nat -A OUTPUT -o lo -p tcp --dport 50001 -j REDIRECT --to-port 50000
    #9 more similar port forwards to port 50000
    iptables -t nat -A OUTPUT -o eth0 -p tcp --dport 50001 -j REDIRECT --to-port 50000
    #9 more similar port forwards to port 50000


    Any help would be appreciated.

  2. #2
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    Why are you using REDIRECT on the output?
    REDIRECT is only for packets that stay on the system.

    Where are you using these rules?
    On the server hosting the website?

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •