Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm in the process of shutting down an old FreeBSD 6.1 server, but I need to port foward 80 & 443 to its replacement while I wait for those naughty ISPs that cache DNS records longer than my TTL to get their act together.

How do I do it?

share|improve this question
up vote 1 down vote accepted

L7 solution:
You can use nginx as a reverse proxy and redirect all requests from old IP to new with simple config like this:

server {
    listen 80;
    listen 443 default ssl;



    location / {
        proxy_pass        http://NEW_IP_HERE/;
        proxy_set_header  Host             $host;
        proxy_set_header  X-Real-IP        $remote_addr;
        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;

L4 solution:

rdr on rl0 proto tcp from any to YOUR_OLD_IP port 80 -> YOUR_NEW_IP 
rdr on rl0 proto tcp from any to YOUR_OLD_IP port 443 -> YOUR_NEW_IP

Do not forget to replace rl0 with your network card name

Then do

# kldload pf
# pfctl -f /etc/pf.conf
# pfctl -e
share|improve this answer

With apache, you can do something like that.

<VirtualHost *:80>
    Redirect permanent /
ServerName *

Using a subdomain will force the a new DNS request. Later you can force the redirection from new to www.

But maybe there is the same domain name and you are just waiting for the DNS to be updated. Then HTTP redirection will not work and some iptable forwarding can be usefull.

ipfw add divert 80 tcp from any to ${my_ip} 80 via ${local_if} in
ipfw add divert 443 tcp from any to ${my_ip} 443 via ${local_if} in

Or you can also put a blank page :

The site is moving, you have to update your DNS to IP_ADDRESS.

Good luck

share|improve this answer
Copying's not good =P – kolypto Nov 13 '09 at 2:35
What do you mean ? – Natim Nov 13 '09 at 6:47

Setup a proxy, or create simple HTTP "Location:" redirection. The more simple - the better: its temporary, don't waste time :)

share|improve this answer
To me, port forwarding is simpler. Location won't work as the only way users are getting to the old server, is if their DNS isn't up to date – aussiegeek Nov 13 '09 at 1:52
ssh forwarding won't be useful: 80 & 443 ports are already occupied on that server. Then you'll need to make your server a router so it forwards everything there (divert with ipfw): it's something like ipfw add divert 1234 tcp from any to ${my_ip} 123 via ${local_if} in. – kolypto Nov 13 '09 at 2:05

Have a look at NetCat, it can listen on a port, redirect to another port on another server is an example of how to do it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.