feature request: migrate rewrite into Main / HTTP

Igor Sysoev is at rambler-co.ru
Sun Mar 11 23:11:47 MSK 2007

On Sat, Mar 10, 2007 at 01:18:50PM -0500, Jonathan Vanasco wrote:

> Would it be possible to migrate some of the rewrite functions out of  
> rewrite and into other sections?
> I say this because documentation wise, and compilation wise , its  
> very awkward -- things are not really where you expect them to be
> suggestion:
> 	Migrated to Main - control functions
> 		break
> 		if
> 		return
> 		set
> 		uninitialized_variable

It's not possible for reasons descreibed below.

> 	Migrated to HTTP
> 		return

What it should "return" at http level ?

http {
    return 404;


> 	Stays the same -
> 		rewrite
> I can't imagine why someone would compile nginx without rewrite -  
> other than mistake.  but having the control functions and return  
> function in rewrite makes them very much 'hidden' from the main  
> documentation.

nginx has three type of configuration directives:

1) static: the most directives,
2) partially dynamic: the directives with $variable paramters,
3) and dynamic: if/rewrite/set/break/return.

The static directives are compiled into binary structures for each
server and locations and they are usually availabe via three and
so memory accesses.

The partially dynamic directives are also compiled into binary structures
and besides the dynamic parts are compiled into some code that run at
request processing stage.

The dynamic directives are compiled into some code that run at
request processing stage. They can not be used to choose configuration

Initially the rewrite module was developed under the influence of Apache's
mod_rewrite (the "rewrite" direcive). Then the "if" block appeared and
this block configuration is considred as some static location configuration:
if you use

    if (some_true_value) {
        configuration A

    if (some_true_value_too) {
        configuration B

you get configuration B, but not A+B. To use configuration A, you
should use the "break" inside first block.

I do not like the current state of rewrite module, but still did not decide
how to change it internally to allow dynamic configurations. There is
currently the only workaround:

   # static
   if (...) {
       limit_rate  1k;

   # fully dynamic:
   if (...) {
       set $limit_rate  1k;

Igor Sysoev

More information about the nginx mailing list