[Solved]-What are the differences between http and socket inside of ini file in uWSGI?

9đź‘Ť

expanding on what Ranjeet said, you need to make sure everything is communicating using compatible protocols. Nginx’s uwsgi_pass option tells it to use a “special” uwsgi protocol. while uWSGI’s socket option is documented as using its “default protocol” which seems to actually mean it uses the same “special” uwsgi protocol, but you could use the uwsgi-socket option to be more explicit.

looking through uwsgi’s the code in uwsgi.c and socket.c it’s pretty obvious that uwsgi-socket is just an alias for socket. it’d be nice if the docs also said that!

if you configure uWSGI with the http option you’re telling it to use the http protocol, which won’t do anything useful because NGINX is trying to talk to it using the above special uwsgi protocol. note that you could also configure NGINX to talk to uWSGI using HTTP, but this would lose information as you’re basically then proxying and NGINX would have to rewrite headers to say it was proxying and would basically end up doing more work

see also https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html which has got lots of stuff about getting things taking to each other, you can just ignore the Django bits!

👤Sam Mason

7đź‘Ť

Don’t confuse with these two different items (uwsgi and http).

As you already mentioned, you are deploying python application with uwsgi and nginx server.

Before go further, look on the client request to server (nginx)

Browser <-> nginx <-> socket <-> uwsgi <-> python application.

Nginx is responsible for to serve html, javascript and css files.

Nginx can’t communicate with python application directly. Because python application standard way to publish applications via web server is WSGI. That’s why we need a uwsgi server. That basically communicate with python application and handle request and response from/to web server nginx.

And Web server/ HTTP server communicate with uwsgi server via socket connection.

However, when I use nginx with uwsgi, I should use socket instead of http. If I use http, I guess the server emitted timeout error.

Yes your right.

👤Ranjeet Singh

Leave a comment