设置应用程序URL前缀与枪支

发布于 2025-01-29 18:29:57 字数 504 浏览 4 评论 0原文

由于多过程池支持,我目前正在将基于金字塔WSGI的应用程序从女服务员Web服务器移至Gunicorn Web服务器。

目前,该应用程序正在为女服务员提供:

from waitress import serve

serve(app,
      host='127.0.0.1',
      trusted_proxy="127.0.0.1",
      threads=32,
      port=port,
      trusted_proxy_headers="forwarded",
      url_scheme=scheme,  # HTTPS 
      url_prefix='/api')

现在,我想与Gunicorn一起服务同一申请。我设法在Gunicorn上找到了所有匹配选项,但没有url_prefix。设置应用程序URL前缀的枪支等效是什么(我认为这有时也称为应用程序根)?

I am currently moving Pyramid WSGI based application from the Waitress web server to Gunicorn web server due to multiprocess pooling support.

Currently, the application is being served with Waitress as:

from waitress import serve

serve(app,
      host='127.0.0.1',
      trusted_proxy="127.0.0.1",
      threads=32,
      port=port,
      trusted_proxy_headers="forwarded",
      url_scheme=scheme,  # HTTPS 
      url_prefix='/api')

Now, I would like to serve the same application with Gunicorn. I managed to find all matching options on Gunicorn, but not url_prefix. What is Gunicorn equivalent for setting the application URL prefix (I think this is sometimes also called application root)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞美少年 2025-02-05 18:29:57

一个人可以使用“ noreferrer”> script_name 环境在枪中的变量以配置WSGI应用程序根。

这是一个示例:

# name is for Datadog agent
# bind matches one in Caddyfile config
# give enough worker processes, threads will have GIL issues
# use SCRIPT_NAME to prefix our API
gunicorn --name backend --bind 127.0.0.1:3456 --workers 8 --threads 2 "backend.server.server:gunicorn_entry_point()" --env "SCRIPT_NAME=/api"

另请参见相关的caddfyfile

One can use SCRIPT_NAME environment variable in Gunicorn to configure the WSGI application root.

Here is an example:

# name is for Datadog agent
# bind matches one in Caddyfile config
# give enough worker processes, threads will have GIL issues
# use SCRIPT_NAME to prefix our API
gunicorn --name backend --bind 127.0.0.1:3456 --workers 8 --threads 2 "backend.server.server:gunicorn_entry_point()" --env "SCRIPT_NAME=/api"

See also related Caddfyfile.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文