Welcome! Log In Create A New Profile

Advanced

Re: Port forwarding problem

Francis Daly
July 26, 2011 09:00AM
On Tue, Jul 26, 2011 at 04:38:09PM +0400, Igor Sysoev wrote:
> On Tue, Jul 26, 2011 at 01:30:19PM +0100, Francis Daly wrote:
> > 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.
>
> "server_name_in_redirect off" forces to use client Host or, if there is
> no Host, server IP.

If the client sends

Host: hostname:1234

then "server_name_in_redirect off" causes nginx to redirect using

http://hostname/

i.e., it drops the :port from the Host: header. Unless my testing
is broken.

It might be convenient to have an option of "use exactly what the
client sent", but that won't be very useful if the client sends a
broken hostname. ngx_http_validate_host() protects against the broken
hostname now.

But I don't have a patch to offer.

> However, this is probably issue with mediawiki.
> If mediawiki is run via FastCGI, then setting
>
> fastcgi_param SERVER_NAME MYNAMEl;
> fastcgi_param SERVER_PORT 55555;
>
> may help.

Yes -- it would be good to show whether the redirect is coming from
nginx or mediawiki.

To the original poster: make a directory "temp" in your document root,
then do "curl -v http://NAT_IP:55555/temp", and if your nginx config
is such that that request will be handled internally within nginx, you
should see a HTTP 301 redirect to /temp/; if the full Location: header
shows port 55555, then nginx is processing the redirect as you intend,
and the original problem is likely best solved via mediawiki.

All the best,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Port forwarding problem

Quincy July 26, 2011 06:35AM

Re: Port forwarding problem

Igor Sysoev July 26, 2011 08:14AM

Re: Port forwarding problem

Quincy July 27, 2011 05:59AM

Re: Port forwarding problem

Francis Daly July 26, 2011 08:32AM

Re: Port forwarding problem

Igor Sysoev July 26, 2011 08:40AM

Re: Port forwarding problem

Francis Daly July 26, 2011 09:00AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 272
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready