How nginx implements the function of jumping to a specified interface

王林
Release: 2020-09-28 16:51:21
forward
3175 people have browsed it

How nginx implements the function of jumping to a specified interface

场景描述:

(推荐教程:nginx教程

进行stub测试时,程序访问的不是真正的接口,而是stub接口(提供假数据).但是程序中写的域名,不可能写stub的ip.如果写死stub的ip,那么到时候上线时还得改代码.(只要动代码,就是有风险的)所以就需要做一个映射.

配置文件名称:yunmasoft.com.conf

配置文件内容:

server {
        listen 80;
        server_name yunmasoft.com www.yunmasoft.com;
        if ( $uri ~* "^/user/loginInput$" ) {
                rewrite ^/(.*)$ http://123.57.250.51/$1 redirect;
        }
        location / {
                proxy_pass    http://182.92.97.72:8083;
                # proxy_redirect on ;

                index index.php index.html index.htm;
        }
        error_page 500 502 503 504 /50x.html;


}
Copy after login

How nginx implements the function of jumping to a specified interface

The above is the detailed content of How nginx implements the function of jumping to a specified interface. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template