Using uWSGI to proxy certain requests

Viewed 423

I am trying to send all requests /other to another server, say google for example. As far as I understand the config I should be able to do something like this in the config file:

[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

This does not work as the log just has

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)
1 Answers

according to the uwsgi doc, you need to specify the external HTTP server address in form of HOST:PORT, for example, with config:

route-if = equal:${PATH_INFO};/s http:220.181.111.188:80,www.baidu.com

result:

[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)
Related