Welcome! Log In Create A New Profile

Advanced

Re: Rewriting/proxy_pass example

Igor Sysoev
December 09, 2009 02:22AM
On Wed, Dec 09, 2009 at 10:08:59AM +0300, Igor Sysoev wrote:

> On Tue, Dec 08, 2009 at 02:24:13PM -0600, Todd Gruben wrote:
>
> > my goal is the following
> >
> > i want requests that come in this format...
> >
> > http://d1.example.com
> > http://d2.example.com
> > .
> > .
> > http://dn.example.com
> >
> > to proxy through to my web server as
> >
> > http://hardcode.example.com/?site=d1
> > http://hardcode.example.com/?site=d2
> > .
> > .
> > http://hardcode.example.com/?site=dn
> >
> > I would also like to pass the uri as is and just append the site=d1 to the
> > request. for example
> >
> > http://d1.example.com/processRequest?arg=1
> >
> > to become
> > http://hardcode.example.com/processRequest?arg=1&site=d1
> >
> >
> > Can the proxy_pass/rewrite combination achieve this pattern?
> >
> >
> > I believe that hardcode.example.com doesn't have to be the same domain as
> > the src, its the moving of the subdomain to the argument parameter which i
> > desire.
>
> 0.8.29:
>
> # you should define the upstream to not resolve the host in runtime
> upstream hardcode.example.com {
> server hardcode.example.com;
> }
>
> server {
> server_name ~^(?<site>d\d+)\.example\.com$;
>
> location {
> proxy_pass http://hardcode.example.com$request_uri?site=$site;

- proxy_pass http://hardcode.example.com$request_uri?site=$site;
+ proxy_pass http://hardcode.example.com$uri?site=$site&$args;

> }
> }
>
> more early:
>
> upstream hardcode.example.com {
> server hardcode.example.com;
> }
>
> server {
> server_name ~^(d\d+)\.example\.com$;
>
> location {
> proxy_pass http://hardcode.example.com$request_uri?site=$1;

- proxy_pass http://hardcode.example.com$request_uri?site=$1;
+ proxy_pass http://hardcode.example.com$uri?site=$1&$args;

> }
> }


--
Igor Sysoev
http://sysoev.ru/en/

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

Rewriting/proxy_pass example

Todd Gruben December 08, 2009 03:32PM

Re: Rewriting/proxy_pass example

edogawaconan December 08, 2009 09:36PM

Re: Rewriting/proxy_pass example

Igor Sysoev December 09, 2009 02:14AM

Re: Rewriting/proxy_pass example

Igor Sysoev December 09, 2009 02:22AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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