举例来说:
docdoc server 上配置了一个 url /category/daily 其状态为开发中,配置其响应数据为 [默认每日聚焦] (注:可以是任意数据,html,json,xml 等),通过 docdoc server 所在地址访问这个 url http://localhost:9981/category/daily 将会得到配置的响应数据 [默认每日聚焦] ,每个用户还可以设置自定义的响应数据,满足多个前端各用各的模拟数据的需求
dochelper 本质上就是从 docdoc 上拉取配置,然后配置 nginx 启动 nginx,配置完的 nginx 大致如下面这样
helper-nginx.conf
worker_processes 2;
events {
worker_connections 1024;
}
http {
upstream program_server {
server
www.chuapp.com;
}
upstream mock_server {
server 192.168.1.21:9981;
}
index index.html index.htm index.php;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
root html;
location / {
proxy_redirect off;
proxy_set_header Host
www.chuapp.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
proxy_pass http://program_server;
}
location /category/daily {
proxy_redirect off;
proxy_set_header Host 192.168.1.21:9981;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header owner fz;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
proxy_pass http://mock_server;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}