1.反向代理,简单点来说就是外网访问内网,比方你在银行,银行一般是内网,现在第三方请求要进来,必须通过银行内部的网关或者市面上留下的网关nginx
2.正向代理,就是内网访问外网,也可以通过阿帕奇的httpclient来访问第三方接口。
反向代理:
以一个例子举例:
server{
listen: 8000 映射的端口
server_name localhost 映射的域名
location / {
root html;
index index.html index.htm;
}
#这是固定写法,主要是设置根目录和首页
localhost /jsh/api/ {
proxy_pass http://73.155.123.15:8945/jsh/api
} #proxy_pass固定写法,
#http://73.155.123.15:8945/jsh/api则是要访问的真实接口,而localhost:8000,只是暴露给第三方外网所访问的接口。
其余的属性网上也很多解释,这里就不多赘述。
}
server{
listen: 8000 映射的端口
server_name _映射的域名
location / {
root html;
index index.html index.htm;
}
#这是固定写法,主要是设置根目录和首页
localhost /jsh/api/ {
proxy_pass http://73.155.123.15:8945/jsh/api
}
当中的
}