Welcome! Log In Create A New Profile

Advanced

C based URI rewrites with standard proxy

Posted by OpusSoup 
C based URI rewrites with standard proxy
January 04, 2012 02:40PM
I'm sure what I'm wanting to do is possible with nginx, but it's isn't clear to me how to achieve it. I'd like for nginx to be able to receive a browser request that is handed to a C module I will code that will alter the URI (based on values returned by a MySQL database). Then I would like the standard proxying abilities of nginx be used to proxy the content from a private BE to the client based on the altered URI.

My thinking is I need to use a C module for the URI rewrite since I need to alter it based on data from a database. It isn't obvious to me how to code this. I've been using ngx_http_rewrite_module.c as a guild, but there's a lot going on in the code. Is a simpler example available I might reference?

Also, the only URIs I'd like nginx to proxy are ones returned by the C module. I'd never want a URI submitted by a client to be proxied directly.

Any suggestions are appreciated!
Re: C based URI rewrites with standard proxy
January 04, 2012 07:23PM
I found what I was looking for here: http://www.evanmiller.org/nginx-modules-guide-advanced.html

The non obvious part for me is the various ways in which a handler can indicate it has completed doing what it needed to do and how it must return so as to allow other modules to pick up handling the request in the right stage of processing. In this case, returning ngx_http_internal_redirect() was what I needed to do.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

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