nginx forwarding learning records

1. Forward the page request and obtain the corresponding parameters

Goal Outcome:

Original address: https://cx.shouji.360.cn/phonearea.php?number=13590431825

Access address after forwarding: http://119.3.251.136/getPhonarea?number= 13590431825

 nginx configuration:

   location /getPhonearea/ {
           proxy_set_header Host $proxy_host;
           proxy_set_header  X-Real-IP         $remote_addr; # pass on real client's IP
           proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
           if ($query_string ~ "number=(.*)") {
                set  $age  $1;
                rewrite ^ /phonearea.php?number=$age break;
           }
           proxy_pass http://cx.shouji.360.cn/;
  }

Guess you like

Origin blog.csdn.net/qq_35008624/article/details/118527146