gpt4 book ai didi

nginx - 为什么 nginx 声称在我的 `rewrite` 语句中没有终止分号?

转载 作者:行者123 更新时间:2023-12-03 23:31:31 28 4
gpt4 key购买 nike

当且仅当 cookie 存在时,我想将 URL 重定向到 Django 平台(通过 uwsgi)。否则,我需要将执行推迟到 content_by_lua插入。

以下是我对这种逻辑的尝试:

location ~* "^/[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$" {  # match a UUID v4
include uwsgi_params;
if ($cookie_admin) {
# if cookie exists, rewrite /<uuid> to /modif/<uuid> and pass to uwsgi
rewrite ^/([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})$ /modif/$1 break;
uwsgi_pass frontend;
}
content_by_lua '
ngx.say("Ping! You got here because you have no cookies!")
';
}

Nginx 认为用以下日志消息侮辱我的智商是必要和适当的:
nginx: [emerg] directive "rewrite" is not terminated by ";" in /opt/openresty/nginx/conf/nginx.conf:34

也许我和 nginx 看起来一样密集,但我错过了什么?

奖金问题:我的一般方法安全和理智吗?有没有更好的方法来实现我的目标?

最佳答案

这对我来说实际上是一件非常愚蠢的事情。 Nginx 使用花括号 {}分隔块,因此当这些用于正则表达式时,表达式必须用双引号括起来。

关于nginx - 为什么 nginx 声称在我的 `rewrite` 语句中没有终止分号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34844728/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com