Welcome! Log In Create A New Profile

Advanced

Re: Reverse proxy : preserving base url

Francis Daly
April 15, 2013 02:06PM
On Sat, Apr 13, 2013 at 10:35:47PM -0400, mastah wrote:

Hi there,

> I've a sub domain which we will call : sub.example.com
> I've an internal application at 127.0.0.1:9090/app
>
> What I would like :
> I would like to proxy sub.example.com to 127.0.0.1:9090/app and i want to
> keep my URL as sub.example.com
> So far I've done countless try without success.

There are two distinct parts to this.

You have the http headers, and you have the body (which will be html or
css or jpg or something else).

nginx can reasonably be expected to adjust the response http headers.

nginx can't reasonably be expected to adjust the response body.

Unless you put in special configuration, nginx with proxy_pass will
probably adjust the response headers for you.

You can try to adjust the body. You will have to match every string
that your client browser will interpret as a url, and make sure that it
works when the browser considers it relative to the non-/app/ url that
it started with.

> The optimal situation would be that when I do :
> http://sub.example.com/ I get the content from http://127.0.0.1:9090/app
> but without any change in the sub domain URL.
>
> So for example if the internal app has
> http://127.0.0.1:9090/app/magical.css, my sub domain should be
> http://sub.example.com/magical.css (without app/)

The cleanest way to achieve this is for you to configure your application
either (a) to believe that it is installed at "/", not at "/app/"; or
(b) to never create any links that start with "/".

In each of those cases, the browser should interpret relative links
correctly without nginx having to modify any body content.

(If you use option (b) and create links like "../../../app/other/place",
then that will break this. So don't do that.)

f
--
Francis Daly francis@daoine.org

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

Reverse proxy : preserving base url

mastah April 13, 2013 10:35PM

Re: Reverse proxy : preserving base url

Francis Daly April 15, 2013 02:06PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 266
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