NGINX Unit: Fixing “Value doesn’t exist.”

Jay Rogers avatar
Jay Rogers October 24th, 2023

Background

We’ve been creating Open Source PHP Docker Images. One of the variations that we’re offering is “nginx-unit”. If you’re not aware, NGINX Unit is a complete alternative to the NGINX web server that you’re probably thinking of. When I was working on providing SSL support, I kept running into the error below.

My attempt

I followed the SSL documentation and would attempt to upload my certificate to NGINX Unit:

/usr/bin/curl -s -w %{http_code} -X PUT --data-binary @/etc/unit/config.d/self-signed-web.pem --unix-socket /var/run/control.unit.sock http://localhost/certificates/self-signed-web

In my case, my certificate bundle is called self-signed-web.

Error message

The error I kept receiving was:

404: Value doesn't exist.

The solution

I was compiling NGINX Unit from source and Timo Stark pointed out I need to compile NGINX Unit with OpenSSL support.

How to resolve

  1. Ensure you install OpenSSL before building (openssl-dev for Alpine and libssl-dev for Debian)
  2. Add the --openssl flag on your configure command

Example

Here is my Dockerfile where I am doing this:

RUN NCPU="$(getconf _NPROCESSORS_ONLN)" && \
    CONFIGURE_ARGS="--prefix=/usr \
                    --statedir=/var/lib/unit \
                    --control=unix:/var/run/control.unit.sock \
                    --runstatedir=/var/run \
                    --pid=/var/run/unit.pid \
                    --logdir=/var/log \
                    --log=/dev/stdout \
                    --tmpdir=/var/tmp \
                    --user=www-data \
                    --group=www-data \
                    --openssl" && \
    ./configure $CONFIGURE_ARGS && \
    ./configure php --config=php-config --module=php && \
    make -j $NCPU all && \
    make install

Notice where I added --openssl above.

Long story, short

Be sure you’re compiling NGINX Unit with OpenSSL support. By default, it does not have the API endpoint enabled and will return “Value doesn’t exist.” if you don’t have your options set correctly.

Support future content

The Ultimate Guide to Building APIs and Single-Page Applications with Laravel + VueJS + Capacitor book cover.

Psst... any earnings that we make off of our book is being reinvested to bringing you more content. If you like what you read, consider getting our book or get sweet perks by becoming a sponsor.

Written By Jay

Jay Rogers avatar Jay Rogers

Iā€™m a DevOps engineer who accidentally ended up in application & user-experience design. ?? I'm a husband and proud dog-dad who co-founded 521 Dimensions & Server Side Up. I like to having meaningful conversations with people who love building things. Please reach out and say hello!

Like this? Subscribe

We're privacy advocates. We will never spam you and we only want to send you emails that you actually want to receive. One-click unsubscribes are instantly honored.