1,網關
網關(Gateway)就是一個網絡連接到另一個網絡的“關口”。
在Nginx 配置負載均衡之后,可以進入到網關,在網關決定進入到哪個真實的web 服務器。
2,將Ngnix 配置 API 網關
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location /project-a {
proxy_pass http://127.0.0.1:8000/;
index index.html index.htm;
}
location /project-b {
proxy_pass http://127.0.0.1:8001/;
index index.html index.htm;
}
}
}
通過攔截url 請求,如果是project-a 就走http://127.0.0.1:8000/ project-b 就走http://127.0.0.1:8001/;