Unit: Listen on unix domain socket (like uwsgi)

Created on 9 Nov 2017  路  5Comments  路  Source: nginx/unit

Can we use unix domain sockets for the unit listeners and use them in nginx proxy_pass?
This would radically simplify deployment of multiple webapps.

Most helpful comment

Yes, unix domain sockets can be used in the same format as in nginx: "unix:/path/to/socket". The only issue now is the sockets are not deleted on unit exit or reconfiguration so you have to delete them manually. However we will fix this bug soon.

All 5 comments

Yes, unix domain sockets can be used in the same format as in nginx: "unix:/path/to/socket". The only issue now is the sockets are not deleted on unit exit or reconfiguration so you have to delete them manually. However we will fix this bug soon.

@sandeep048 We will keep this issue open until we add the remaining features related to socket handling.

Just to clarify further, the following would be a minimal socket config:

{
    "listeners": {
        "unix:/tmp/app.sock": {
            "application": "myapp"
        }
    },

    "applications": {
        "myapp": {
                        ... app settings here ...
        }
    }
}

Will this functionality be implemented?

How can one address a socket listener via the API? The equivalent of <host>/config/listeners/<ip>:<port>/,

<host>/config/listeners/unix:/path/to/socket/

does not seem to work.
Also, any update on when the automatic deletion of sockets will be implemented?

@lcts Addressing of such socket name isn't something supported right now. There's a plan to make it possible via URI-escaping, e.g.: /config/listeners/unix:%2Fpath%2Fto%2Fsocket/.

Sorry, still no updates on automatic deletion. Frankly speaking, the full support of listening on unix domain sockets isn't our priority, since Unit is not meant to be put behind local reverse proxy.

Was this page helpful?
0 / 5 - 0 ratings