可以使用uwsgi协议调用http吗? [英] Can I use the uwsgi protocol to call http?

查看:55
本文介绍了可以使用uwsgi协议调用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 来测试 webapp 中的 API 怎么办?

What if I want to directly call uWSGI to test an API in a webapp?

实际上我正在使用金字塔.只需在 .ini 中配置 [uwsgi] 并运行 uWSGI.但我想测试uWSGI是否正常保持webapp功能,uWSGI套接字不能通过http直接访问.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆