Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache mod_proxy_uwsgi and unix domain sockets

I have a uwsgi server running for unix domain socket

[uwsgi]
...
socket = /var/run/someuwsgi.sock
socket = localhost:9987
...

The mod_proxy_uwsgi is installed

In apache config has that line: ProxyPass /some uwsgi://localhost:9987

And it is working.

Question: what should be the apache config line to go through unix domain socket /var/run/someuwsgi.sock ? I tried

ProxyPass /some uwsgi:///var/run/someuwsgi.sock

and got

Bad Request
Your browser sent a request that this server could not understand.

Also tried

ProxyPass /some uwsgi://unix:///var/run/someuwsgi.sock

and got

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /some/.

Reason: DNS lookup failure for: unix:

Thanks!

like image 427
user3177400 Avatar asked Jan 09 '14 12:01

user3177400


People also ask

What is the difference between Unix socket and TCP socket?

A UNIX socket is an inter-process communication mechanism that allows bidirectional data exchange between processes running on the same machine. IP sockets (especially TCP/IP sockets) are a mechanism allowing communication between processes over the network.

What are Unix domain socket connections?

A Unix domain socket aka UDS or IPC socket (inter-process communication socket) is a data communications endpoint for exchanging data between processes executing on the same host operating system. It is also referred to by its address family AF_UNIX .

Are UNIX sockets blocking?

The traditional UNIX system calls are blocking. For example: accept() blocks the caller until a connection is present. If no messages space is available at the socket to hold the message to be transmitted, then send() normally blocks.

Are UNIX domain sockets reliable?

Valid socket types in the UNIX domain are: SOCK_STREAM, for a stream-oriented socket; SOCK_DGRAM, for a datagram-oriented socket that preserves message boundaries (as on most UNIX implementations, UNIX domain datagram sockets are always reliable and don't reorder datagrams); and (since Linux 2.6.


1 Answers

Starting from Apache 2.4.7, support for Unix sockets has been added. The syntax is pretty simple:

ProxyPass / unix:/tmp/uwsgi.sock|uwsgi://
like image 107
LennyLip Avatar answered Sep 17 '22 17:09

LennyLip