Port forwarding problem

Francis Daly francis at daoine.org
Tue Jul 26 12:30:19 UTC 2011

On Tue, Jul 26, 2011 at 06:35:23AM -0400, Quincy wrote:

Hi there,

> I have two machines. One is server with nginx and the other is NAT.
> On server I've got mediawiki on port 2222. I forwared port 55555 on my
> nat to server:2222. I have one big problem. When I try to open
> NAT_IP:55555 in my browser it redirects me to http://:2222.  What's
> wrong with my config?

I don't see a pure-config way to tell nginx to redirect using exactly
the Host: header sent by the client. I think that that is probably what
you want to have.

You can "work around" it if you are happy to insist that the client uses
one specific host:port url to access the service:

> Here is my virtualhost config file:
>   1 server {
>   2   listen 2222;
>   3   server_name MYNAMEl;

server_name NAT_IP:55555;

>   4   server_name_in_redirect off;

server_name_in_redirect on;

>   5   port_in_redirect off;

Good luck with it,

Francis Daly        francis at daoine.org

More information about the nginx mailing list