注意: 本站使用的nginx
反向代理架设的Https
location = /api/hello {
echo "hello, world!";
}
# 反向代理添加前置、后置内容
location = /api/proxy_before_after {
echo_before_body echo_before_body;
echo_before_body echo_before_body;
proxy_pass http://127.0.0.1;
echo_after_body echo_after_body;
echo_after_body echo_after_body;
}
# sleep测试
location ~* ^/api/sleep(\/\d*\/?)?$ {
echo "{";
echo " request_uri=$request_uri";
set $time 2;
if ($uri ~* ^(.+?)/(\d+)/?$) {
set $time $2;
}
echo_sleep $time;
echo " time=$time";
echo "}";
}
# 模拟combo
location = /api/combo {
echo_foreach_split ',' $query_string;
echo "/* combo: $echo_it */";
echo_location_async $echo_it;
echo;
echo_end;
}
# 输出内容
location ~* ^/api/echo(\/[^\/]*?\/?)?$ {
set $str 'null';
if ($uri ~* ^/api/echo/([^\/]+)/?$) {
set $str $1;
}
echo $str;
}
有任何问题可在: https://github.com/xuexb/echo.xuexb.com/issues 反馈给我~ 感谢~