使用uWSGI代理特定的请求

9

我想将所有请求/other发送到另一台服务器,比如说谷歌。据我所知,我应该能够在配置文件中像这样做:

[uwsgi]
master = 1
buffer-size = 65535
die-on-term = true
# HTTP
http-socket = 0.0.0.0:80
# App
module = manage:app
# Async processes
gevent = 100
processes = 4
route-if = equal:${PATH_INFO};/other http:216.58.204.78,www.google.com

这样做是无效的,因为日志只显示了

error routing request to http server 216.58.204.78
[pid: 9|app: -1|req: -1/11] 172.18.0.1 () {36 vars in 759 bytes} [Thu Sep 20 14:51:55 2018] GET /other => generated 0 bytes in 0 msecs via route() (HTTP/1.1 500) 0 headers in 0 bytes (1 switches on core 99)

3
为什么不使用NGINX呢? - andercruzbr
1个回答

4
根据uwsgi文档,你需要指定外部HTTP服务器地址的格式为HOST:PORT,例如,使用以下配置:
route-if = equal:${PATH_INFO};/s http:220.181.111.188:80,www.baidu.com

结果:

[pid: 5113|app: -1|req: -1/1] 127.0.0.1 () {24 vars in 249 bytes} [Tue Sep 25 17:58:33 2018] GET /s => generated 118322 bytes in 34 msecs via route() (HTTP/1.1 200) 18 headers in 944 bytes (0 switches on core 0)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接