Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using uWSGI to proxy certain requests

Tags:

python

uwsgi

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)
like image 536
RexFuzzle Avatar asked Sep 20 '18 15:09

RexFuzzle


People also ask

How many requests can uWSGI handle?

Running uWSGI in Async mode Each async core can manage a request, so with this setup you can accept 10 concurrent requests with only one process. You can also start more processes (with the --processes option), each will have its own pool of async cores.

Can I use uWSGI without Nginx?

Can I then ditch NGINX? uWSGI could be used as a standalone web server in production, but that is not it's intentional use. It may sound odd, but uWSGI was always supposed to be a go-between a full-featured web server like NGINX and your Python files.

Which is better Gunicorn or uWSGI?

Gunicorn and uWSGI are primarily classified as "Web Servers" and "Web Server Interface" tools respectively. Gunicorn and uWSGI are both open source tools. Gunicorn with 5.96K GitHub stars and 1.12K forks on GitHub appears to be more popular than uWSGI with 2.5K GitHub stars and 541 GitHub forks.

What is uWSGI used for?

uWSGI is an open source software application that "aims at developing a full stack for building hosting services". It is named after the Web Server Gateway Interface (WSGI), which was the first plugin supported by the project.


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)
like image 158
georgexsh Avatar answered Nov 15 '22 00:11

georgexsh