nginx如何實(shí)現(xiàn)跳轉(zhuǎn)到指定接口的功能

nginx如何實(shí)現(xiàn)跳轉(zhuǎn)到指定接口的功能

場景描述:

(推薦教程:nginx教程

進(jìn)行stub測試時,程序訪問的不是真正的接口,而是stub接口(提供假數(shù)據(jù)).但是程序中寫的域名,不可能寫stub的ip.如果寫死stub的ip,那么到時候上線時還得改代碼.(只要動代碼,就是有風(fēng)險的)所以就需要做一個映射.

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

配置文件內(nèi)容:

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;   }

nginx如何實(shí)現(xiàn)跳轉(zhuǎn)到指定接口的功能

以上就是

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊11 分享