NGINX Unit: Fixing “Value doesn’t exist.”
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
- Ensure you install OpenSSL before building (
openssl-dev
for Alpine andlibssl-dev
for Debian) - 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.