Before saying anything, I would like you to know that my experience in the field of network administration is about 3 days long, so please treat me like the newbie I am. I have also been looking around 2 of these 3 days trying to find the best way to achieve my objective, and I have found similar questions around the internet, but I have not been able to do it.

I am running an Apache2 server on localhost:8080 from a Mac OS X fully updated Lion. This Mac is connected through Ethernet (interface en0) to a wireless Access Point. In the AP, I have set up the gateway to be, and I have given that IP address to en0. The objective of this network is redirecting anyone's http/https petitions to the localhost of the gateway, showing them the page that apache is serving.

-If before this point there's any conceptual mistake, please let me know-

As far as I have understood, the best way to do this redirection is using the pf.conf file and pfctl, but the man page of pf.conf left me with a bit of a WTF face. I have found in freebsdonline.com these instructions to do something similar:

# --------- pf.conf ----------

rdr on $int_if inet proto tcp from any to any port www -> port 8080
pass in on $int_if inet proto tcp from any to port 8080 keep state
pass out on $ext_if inet proto tcp from any to any port www keep state
# ------- end pf.conf -------

The thing is that this pf.conf seems to be forwarding packets between 2 interfaces, and I dont need that (do I?). Could you help me to adapt, or at least understand that lines? And is there anything else I need to do once that lines have been added to pf.conf?

P.S: If you know any easier way of doing this redirection stuff, I'll be glad to hear it. I though about using dnsspoof, but I haven't been able to find it for OSX.

1 Answer 1


Since you didn't mention it, I would make sure to navigate to:


and open (using your text editor of choice; vi/m works, of course)


Once you're there, make sure that lines 39 and 40 (or thereabouts) read:

Listen *your_web_site's_address*:8080  
Listen 8080  

If it reads

Listen 80  

Then that is certainly a big part of your problem, as the server is listening on the wrong port altogether. As always, make sure to properly configure your firewall(s)!

  • Thanks for the answer :) Anyway, I have already got the httpd.conf configured like that. I can access the website writing localhost:8080, and from other computers pointing The problem is that when I redirect the traffic (now I'm doing it with dnsspoof) to my address, I don't know how to specify the port, and it automatically points the port 80 (which, I don't know why, says I don't have permissions to use it).
    – Palantir
    Feb 16, 2012 at 19:47
  • I forgot to ask if you had properly forwarded ports on your router. From your original post it looks like "anyone's" requests means just that, whether it is LAN or WAN. Is that accurate? If so, then the router needs to forward requests for port 8080 (which should be part of the website name requests) to the machine hosting the web site.
    – soxman
    Feb 17, 2012 at 0:31
  • Actually, there is no WAN. My computer is doing the router role, but as I only want the clients to communicate with my apache server, I don't need to forward packets or open open ports to outside the network.
    – Palantir
    Feb 18, 2012 at 9:58
  • I have finally managed to get this working on linux, using dnsspoof, because linux' apache is able to use port 80 without giving me problems. Anyway, as using virtual machines all the time is quite disgusting, I'm not closing this topic to see if someone is able to help me to make it work on OSX :) Thanks for your help
    – Palantir
    Feb 18, 2012 at 10:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .