Help us understand the problem. What is going on with this article?

Nginxで複数条件のIF文を書く方法がすごいw

More than 5 years have passed since last update.

NginxでIf文を if ($host = 'www.example.com' && $request_uri ~ "/admin") という風には書けない。
入れ子にもできません。(ディレクティブなので?)

そこで逃げ道は 文字列結合で判定

    if ($request_uri = /) { 
      set $test  A; 
    } 

    if ($host ~* teambox.com) { 
      set $test  "${test}B"; 
    } 

    if ($http_cookie !~* "auth_token") { 
      set $test  "${test}C"; 
    } 

    if ($test = ABC) { 
      proxy_pass http://teambox-cms.heroku.com; 
      break; 
    } 

参考(というかそのものですが)
https://gist.github.com/jrom/1760790

ちなみにifisevilと公式ドキュメントにあります。使わないほうが良さそう。
http://wiki.nginx.org/IfIsEvil

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした