Home  >  Article  >  Backend Development  >  nginx jumps to the specified interface

nginx jumps to the specified interface

WBOY
WBOYOriginal
2016-07-29 09:01:061957browse

nginx 跳转指定接口
场景:
进行stub测试时,程序访问的不是真正的接口,而是stub接口(提供假数据).
但是程序中写的域名,不可能写stub的ip.
如果写死stub的ip,那么到时候上线时还得改代码.(只要动代码,就是有风险的)
所以就需要做一个映射.
使用nginx 实现这个功能
配置文件名称:yunmasoft.com.conf
配置文件内容:

<code><span>server</span> {
        listen <span>80</span>;
        server_name yunmasoft.com www.yunmasoft.com;
        <span>if</span> ( $uri ~* <span>"^/user/loginInput$"</span> ) {
                rewrite ^/(.*)$ http:<span>//123.57.250.51/$1 redirect;</span>
        }
        location / {
                proxy_pass    http:<span>//182.92.97.72:8083;</span><span># proxy_redirect on ;</span><span>index</span><span>index</span>.php <span>index</span>.html <span>index</span>.htm;
        }
        error_page <span>500</span><span>502</span><span>503</span><span>504</span> /<span>50</span>x.html;


}</code>

nginx 跳转指定接口
参考:http://hw1287789687.iteye.com/admin/blogs/2279741

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了nginx 跳转指定接口,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Statement:
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