#2474 closed defect (invalid)

Why is the rewritten uri not validated?

Reported by: 志道 洪 Owned by:
Priority: minor Milestone: nginx-1.23.4
Component: documentation Version: 1.19.x
Keywords: Cc: 志道 洪
uname -a: nobody
nginx -V: 1.19

Description

Hi, I have a question about the nginx rewrite directive.
It's allowed to config any rewritten value in nginx, for example:

server {

listen 8080;

rewrite .*$ "invalid url" break;

location ~ .* {

return 200 $uri;

}

}

Does it mean it's unnecessary to validate URL in nginx? Thanks.

Change History (1)

comment:1 by Maxim Dounin, 20 months ago

Resolution: invalid
Status: newclosed

In general, nginx does what is written in the configuration, even if it's invalid from protocol point of view and/or for some other reason. Correctness of the result is therefore responsibility of the author of the configuration. In some cases this makes it possible to do things which aren't otherwise possible: note that the configuration snippet you've provided actually works.

Note: See TracTickets for help on using tickets.