0

I've a Django app inside a docket that uses uwsgi. Since we have several Dockers running on different machines we have haproxy as load balancer.

My question is: should I use uwsgi with http or http-socket?

From here https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html

It seems http

The http-socket option will make uWSGI natively speak HTTP. If your web server does not support the uwsgi protocol but is able to speak to upstream HTTP proxies, or if you are using a service like Webfaction or Heroku to host your application, you can use http-socket. If you plan to expose your app to the world with uWSGI only, use the http option instead, as the router/proxy/load-balancer will then be your shield.

The last part suggest that http is what to do if there's a load balancer

But here https://uwsgi-docs.readthedocs.io/en/latest/ThingsToKnow.html

The http and http-socket options are entirely different beasts. The first one spawns an additional process forwarding requests to a series of workers (think about it as a form of shield, at the same level of apache or nginx), while the second one sets workers to natively speak the http protocol. TL/DR: if you plan to expose uWSGI directly to the public, use --http, if you want to proxy it behind a webserver speaking http with backends, use --http-socket.

It seems to infer that http-socket if not exposed directly to public

So, what the way to do it with haproxy?

1 Answer 1

1

haproxy doesn't support uWSGI directly. You need to use http-socket. You can also enable support for PROXY protocol with --http-enable-proxy-protocol to preserve a client's IP address.

2
  • I know that does not support uwsgi. But why http-socket and not http? That's my question, which one of the two and why
    – EsseTi
    Commented Feb 9 at 6:58
  • 1
    The docs are a bit confusing. --http doesn't expose uWSGI directly but spawns a process which speaks HTTP and then forwards requests to uWSGI workers. As you already have haproxy you don't need this additional process.
    – AlexD
    Commented Feb 9 at 7:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .