The issue is you have a wave originating not at the rear wall, reflecting off the rear wall and meeting the wave that's already heading forward some bit out of phase. Box all the way to the rear (or in a rear corner) regardless of which direction subs/port face is going to be more reliable and generally better.
As far as where to fire the port, the important bit is really just to keep the opening far enough away from anything else that nothing else is effecting the effective volume or opening area. Generally a port width away from hard walls in the car and the woofer itself is considered adequate.
From there I'd suggest that having sub and port on the same face and pointing the same direction is likely the safest bet but you just won't know until you test and depending on the dimensions of the box, sub, and port required some combinations will be physically impossible. I've had good luck with almost every variation of subs facing up, back, or front and ports going out the same side, a different side, or out the side of the box... depending on the vehicle. For what it's worth the difference between any of those variables usually isn't that dramatic and you really can't predict this so if you're really hung up on optimizing this your only hope is to come up with a good plan on how to be able to modify the box several times to test every variation.