whitebear
whitebear

Reputation: 12423

Nginx unit requires using port 80 for initial setting?

I installed Nginx unit

systemctl status unit
● unit.service - NGINX Unit
     Loaded: loaded (/lib/systemd/system/unit.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2021-09-02 15:33:30 JST; 4min 29s ago
    Process: 2288597 ExecStart=/usr/sbin/unitd $DAEMON_ARGS (code=exited, status=0/SUCCESS)
   Main PID: 2288600 (unitd)
      Tasks: 3 (limit: 2282)
     Memory: 5.6M
     CGroup: /system.slice/unit.service
             ├─2288600 unit: main v1.25.0 [/usr/sbin/unitd]
             ├─2288613 unit: controller
             └─2288614 unit: router

Sep 02 15:33:30 tk2-243-31156 systemd[1]: Starting NGINX Unit...
Sep 02 15:33:30 tk2-243-31156 unitd[2288597]: 2021/09/02 15:33:30 [info] 2288597#2288597 unit started
Sep 02 15:33:30 tk2-243-31156 systemd[1]: Started NGINX Unit.

Now,I try to first test

sudo curl --unix-socket /var/run/unit/control.sock http://localhost/

However it returns curl: (7) Couldn't connect to server

I guess on this service apache works ,so port 80 is used....

Is there any work around??

Upvotes: 1

Views: 483

Answers (1)

KarelHusa
KarelHusa

Reputation: 2263

You can communicate via Unix socket without opening an additional network (IP) socket, e.g. on port 80. Doublecheck your Unix socket path, if it is really /var/run/unit/control.sock.

If I use a non-existing path, e.g.:

/var/run/nonexisting.sock

I get the same error:

curl: (7) Couldn't connect to server

When I run the following command:

sudo curl -X GET --unix-socket /var/run/control.unit.sock http://localhost/status

curl connects to Unix socket and use the HTTP URL to address the REST API behind it. It doesn't use the port 80.

You should get a similar response:

{
    "connections": {
        "accepted": 0,
        "active": 0,
        "idle": 0,
        "closed": 0
    },
    "requests": {
        "total": 0
    },
    "applications": {}
}

Upvotes: 0

Related Questions