Close enough that you can poke the puck away or block a shot, not so close that they can beat you.
Seriously, you want to be fairly close -- the forward should probably be right about as far as you can reach with your stick at full extension. That gives you the reach to cause him problems, but gives you the distance to react to moves.
Body positioning is key; you
never want to give away the inside. Let him go around you to the outside if he really wants to; he's not going to score from the corner. But don't give him that inside lane for anything.
If he puts the puck through your legs or off the boards, just stay in front of him -- it's interference (on him!) if he runs you over. Let the puck go deep into the zone and slow him up so your partner can get it.
One tip someone gave me yesterday is to keep your arms tucked close into your side (elbows right up against your ribs) to make your reach look shorter than it is. That helps sucker the forward close in so you can poke the puck away.