server {
listen 80;
server_name ~^(?<custom>.+)\.(test)?website\.com$;
location ~ ^/event/(\d+)$ {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_intercept_errors on;
# This is the problematic block
# This conditional breaks the whole location block.
# If I commented the if statement, the default proxy_pass works.
if ($http_user_agent ~* iphone|android) {
# the proxy_pass indeed works, tested on development machine
proxy_pass http://frontends/userland/mobile/event/$1;
break;
}
# When above if conditional is enabled, this fails.
proxy_pass http://frontends/userland/event/$1;
}
}
server_name 内のサブドメイン マッチャーはほとんどワイルドカードであることに気付きました。
if 条件が機能しないのはなぜですか? 私がやっていることが間違っている場合、それを書き直す最良の方法は何ですか?
Nginx バージョン: 1.2.0