NGINX Unit: Fixing "Value doesn't exist."

Jay Rogers

October 24th, 2023

Blog post header image

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:

Upload certificate command

/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:

Error message

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:

Dockerfile

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.

Want to work together?

Professional developers choose Server Side Up to ship quality applications without surrendering control. Explore our tools and resources or work directly with us.

Join our community

We're a community of 3,000+ members help each other level up our development skills.

Platinum Sponsors

Active Discord Members

We help each other through the challenges and share our knowledge when we learn something cool.

Stars on GitHub

Our community is active and growing.

Newsletter Subscribers

We send periodic updates what we're learning and what new tools are available. No spam. No BS.

Sign up for our newsletter

Be the first to know about our latest releases and product updates.

    Privacy first. No spam. No sharing. Just updates.