Home According to IP nginx Jump

Scene:
1. When a new service line or page, the need for online testing, but does not affect the user can choose to jump ip development department to the new address
2. Server maintenance need to jump to the ip outside developers maintenance tips page
3. the show ip for different effects in different parts of the home page (requires geoip module fit)

The above scenario can be realized by the following configuration used

LOCATION / {
  IF (* ~ $ REMOTE_ADDR "223.93.188.66") {
    the rewrite HTTPS ^ (*.): // new address / BREAK;
  }
}
or

LOCATION / {
  IF (..? $ REMOTE_ADDR ~ * ^ 223 \ .93 \ .188 \ (*) $) {
    (. *) ^ rewrite HTTPS: // new address / BREAK;
  }
}
supplement regular expression on nginx formula

Case-sensitive match ~

Case-insensitive matching ~ *

! ~ And! ~ * Do not match are case-insensitive and case-insensitive mismatch

^ Matches beginning

$ Matches the end of

.? *, Etc. need to escape
----------------
Original link: https: //blog.csdn.net/lai0yuan/article/details/80784058

Guess you like

Origin www.cnblogs.com/gramblog/p/11446914.html