次の http ブロックを指定すると、nginx は期待どおりに動作します。つまり、http://localhost/3ba48599-8be8-4326-8bd0-1ac6591c2041/
toなどの URL を書き換えhttp://localhost/modif/3ba48599-8be8-4326-8bd0-1ac6591c2041/
て uwsgi サーバーに渡します。
http {
upstream frontend {
server frontend:8000;
}
server {
listen 8000;
server_name localhost;
root /www/;
location ~* "^/([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})/?$" {
include uwsgi_params;
set $uuid $1;
if ($cookie_admin) {
# if cookie exists, rewrite /<uuid> to /modif/<uuid> and pass to uwsgi
rewrite / /modif/$uuid break;
uwsgi_pass frontend;
}
content_by_lua_block {
ngx.say("Ping! You got here because you have no cookies!")
}
}
}
}
しかし、下に表示されている方法で別のブロックを追加するlocation
と、物事が崩壊し、ERR_TOO_MANY_REDIRECTS
.
http {
# access_log /dev/stdout; # so we can `docker log` it.
upstream frontend {
server frontend:8000;
}
server {
listen 8000;
server_name localhost;
root /www/;
location / { # THIS MAKES EVERYTHING FALL APART :(
uwsgi_pass frontend;
include uwsgi_params;
}
location ~* "^/([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})/?$" {
include uwsgi_params;
set $uuid $1;
if ($cookie_admin) {
# if cookie exists, rewrite /<uuid> to /modif/<uuid> and pass to uwsgi
rewrite / /modif/$uuid break;
uwsgi_pass frontend;
}
content_by_lua_block {
ngx.say("Ping! You got here because you have no cookies!")
}
}
}
}
ここで何が起こっているのですか?どうすればこれを修正できますか?