我可以使用uwsgi协议调用http吗? [英] Can I use the uwsgi protocol to call http?
问题描述
这是一个数据流: http<-> nginx<-> uWSGI<-> python webapp
Here's a data flow: http <--> nginx <--> uWSGI <--> python webapp
我猜nginx中有http2uwsgi传输,而uWSGI中有uwsgi2http.
I guess there's http2uwsgi transfer in nginx, and uwsgi2http in uWSGI.
如果我想直接调用uWSGI来测试Web应用程序中的API,该怎么办?
What if I want to directly call uWSGI to test an API in a webapp?
实际上我在用金字塔.只需在.ini中配置[uwsgi]并运行uWSGI.但是我想测试uWSGI是否正常保持webapp功能,http无法直接访问uWSGI套接字.
actually i'm using pyramid. just config [uwsgi] in .ini and run uWSGI. but i want to test if uWSGI hold webapp function normally, the uWSGI socket is not directly reachable by http.
推荐答案
尝试使用uwsgi_curl
$ pip install uwsgi-tools
$ uwsgi_curl 10.0.0.1:3030 /path
或者如果您需要执行更多请求,请尝试使用同一软件包的uwsgi_proxy
or if you need to do some more requests try uwsgi_proxy
from the same package
$ uwsgi_proxy 10.0.0.1:3030
Proxying remote uWSGI server 10.0.0.1:3030 "" to local HTTP server 127.0.0.1:3030...
,因此您可以在 http://127.0.0.1:3030/本地浏览.
so you can browse it locally at http://127.0.0.1:3030/.
如果您的应用程序仅允许某些Host
标头,则还可以指定主机名
If your application allows only certain Host
header, you can specify host name as well
$ uwsgi_curl 10.0.0.1:3030 host.name/path
$ uwsgi_proxy 10.0.0.1:3030 -n host.name
如果应用程序具有静态文件,则可以使用-s
参数将此类请求重定向到前端服务器.如果需要,您还可以指定其他本地端口.
If application has static files, you can redirect such requests to your front server using -s
argument. You can also specify different local port if needed.
这篇关于我可以使用uwsgi协议调用http吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!