The regular asterisk (*) of nginx location does not match the dot (.) The path file of

problem description

1. The background uses X-Accel-Redirect to specify the website of the reverse proxy:

    X-Accel-Redirect: /proxy/domain.com/path/to/index.php?id=1
    
    X-Accel-Redirect: /proxy/domain.com/path/to/index?id=1

location configuration in 2.nginx is similar to the following reverse proxy

    location ~* ^/proxy/(.*?)/(.*){
        set $proxy_host $1;
        set $proxy_uri $2;
        set $proxy_url http://$proxy_host/$proxy_uri$is_args$args;
        proxy_pass $proxy_url;//
    }

for the first agent with the php suffix, this location block is not matched and the page displays 404.
but for the second one without php, it matches normally.
so guess that the reason is that the period (.) in index.php cannot be matched.

Environmental background and what methods have you tried

nginx/1.14.2
attempted method:
reference to match suffixed files like location ~\ .php $ I also try to write location ~ * ^ / proxy/ (. *?) / (. +\ .php) , but the asterisk that cannot be matched should match all characters except newline characters, which is difficult to understand.

see

in nginx document
The matching is performed against a normalized URI, after decoding the text encoded in the "% XX" form, resolving references to relative path components "." And "..", and possible compression of two or more adjacent slashes into a single slash.

parse ".", ".." in url? I don"t know what it means

I would like to ask the boss for some advice. Thank you very much.

May.04,2022

looked at the regular matching order of locatio, and guessed that it might be because this block has a location that matches the php suffix, so this piece is ignored. Probably so. Go back and change the order of location

.
Menu