0

I want to use a test server for administrators.

Is there a way to assign an access from the client of ip(123.0.0.1) to the server of ip(123.0.0.2)?

upstream target-server {  
  server [123.0.0.3] ;
  server [123.0.0.2] ;
}
0

You may use if statement in location to map traffic to your service.

upstream target-server {
server 123.0.0.3 ; 
server 123.0.0.2 ; }
server{
***
  location / {
    if ($remote_addr = 123.0.0.1) {
          proxy_pass http://123.0.0.2 ;
    }
    proxy_pass http://target-server ;
  }
}
  • I want to use like this . 123.0.0.*(all) how can i do ?? – Fehoon Jul 31 '18 at 9:42
  • I believe something like ($remote_addr ~ 123.0.0 ) within if condition may work. There are multiple conditions in nginx. For example this gist.github.com/jrom/1760790 – user2986553 Jul 31 '18 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.