發布於

Nginx Configuration for starter

作者
  • avatar
    名稱
    Kevin Fan
    Twitter
nginx image

關於 Nginx 相關設定,目前只有 Location 相關,未來會持續更新

Location

::: tip 解析順序

  1. Exact match = url
  2. Preferential Prefix match ^~ url
  3. REGEX match ~ regex_url or ~* regex_url
  4. Prefix match url

:::

Prefix match

location /Greet2 {
    return 200 'Hello from NGINX "/greet" location.';
}

Preferential Prefix match

location ^~ /Greet2 {
    return 200 'Hello from NGINX "/greet" location.';
}

Exact match

location = /greet {
    return 200 'Hello from NGINX "/greet" location - EXACT MATCH.';
}

REGEX match - case sensitive

location ~ /greet[0-9] {
    return 200 'Hello from NGINX "/greet" location - REGEX MATCH.';
}

REGEX match - case insensitive

location ~* /greet[0-9] {
    return 200 'Hello from NGINX "/greet" location - REGEX MATCH INSENSITIVE.';
}