Note that there are some explanatory texts on larger screens.

plurals
  1. PONginx map doesn't use the arguments of my regular expression
    primarykey
    data
    text
    <p>I'm trying to use the map of nginx, but the results aren't what I expect.</p> <p>This is what I have:</p> <pre><code>map $uri $new { default ""; ~*/cc/(?P&lt;suffix&gt;.*)$ test.php?suffix=$suffix; } location ~ [a-zA-Z0-9/_]+$ { proxy_pass http://www.domain.com:81/$new; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } </code></pre> <p>When I go to www.domain.com/cc/abc, I see this in the logs</p> <pre><code>2012/03/29 17:27:53 [warn] 3382#0: *33 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/5/00/0000000005 while reading upstream, client: 1.2.3.4, server: www.domain.com, request: "GET /cc/abc HTTP/1.1", upstream: "http://1270.0.0.1:81/test.php?suffix=$suffix", host: "www.domain.com" </code></pre> <p>The $suffix isn't replaced.</p> <p>But when I do this:</p> <pre><code>map $uri $new { default ""; ~*/cc/(?P&lt;suffix&gt;.*)$ $suffix; } location ~ [a-zA-Z0-9/_]+$ { proxy_pass http://www.domain.com:81/$new; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } </code></pre> <p>And now, when I go to go to www.domain.com/cc/abc, the logs show me this:</p> <pre><code>2012/03/29 17:29:39 [warn] 5916#0: *26 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/2/00/0000000002 while reading upstream, client: 1.2.3.4, server: www.domain.com, request: "GET /cc/abc HTTP/1.1", upstream: "http://1270.0.01:81/abc", host: "www.domain.com" </code></pre> <p>So, when the rewrite contains a string including the variable, it isn't replaced. But if it only contains the variable, it will work.</p> <p>What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload