Skip to content

doc: use shared_dict for dynamic certs demo #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2023

Conversation

ivanitskiy
Copy link
Contributor

@ivanitskiy ivanitskiy commented Jul 27, 2023

This demo shows how to use the new shared_dict_zone with NJS v.0.8.0 and up to set up NGINX to serve encrypted traffic without server restarts when the certificate or key changes occur

@ivanitskiy
Copy link
Contributor Author

as NJS v0.8.0 is not available in nginx docker images as of today, you can use:

# syntax=docker/dockerfile:1
ARG NGINX_VERSION=1.25.1
ARG NJS_VERSION=0.8.0
FROM nginx:${NGINX_VERSION}
ARG NGINX_VERSION
ARG NJS_VERSION

RUN --mount=type=cache,target=/var/cache/apt <<EOF
    set -eux
    export DEBIAN_FRONTEND=noninteractive
    apt-get -qq update
    apt-get -qq install --yes --no-install-recommends --no-install-suggests \
        curl gnupg2 ca-certificates debian-archive-keyring inotify-tools
    update-ca-certificates
    apt-get remove --purge --auto-remove --yes
EOF

# As of 07/13/2023 NJS v0.8.0 is not included into nginx docker image.
# This a temprary to install it
# Following installation steps from http://nginx.org/en/linux_packages.html#Debian
RUN --mount=type=cache,target=/var/cache/apt <<EOF
    set -eux
    export DEBIAN_FRONTEND=noninteractive
    apt-get -qq update
    curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
        | tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
    gpg --dry-run --quiet --no-keyring --import --import-options import-show \
        /usr/share/keyrings/nginx-archive-keyring.gpg
    echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
        http://nginx.org/packages/mainline/debian $(echo $PKG_RELEASE | cut -f2 -d~) nginx" \
        | tee /etc/apt/sources.list.d/nginx.list
    apt-get -qq update
    apt-get -qq install --yes --no-install-recommends --no-install-suggests \
        nginx-module-njs=${NGINX_VERSION}+${NJS_VERSION}-${PKG_RELEASE}
    apt-get remove --purge --auto-remove --yes
    rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx.list
EOF

@ivanitskiy ivanitskiy force-pushed the master branch 4 times, most recently from a51762c to 473ac84 Compare July 27, 2023 23:04
README.rst Outdated
* - Validate and sanitize uploaded file content to prevent security risks.
*/

import fs from 'fs'
Copy link
Contributor

@xeioex xeioex Jul 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is an example, I suggest to remove non-essential code from the .rst page, leave only the crucial parts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please take a look again.

README.rst Outdated

Note: this example below work with njs >= `0.8.0 <http://nginx.org/en/docs/njs/changes.html#njs0.8.0>`_.

This example demonstrtaes:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

demonstrtaes -> demonstrates

}


Here we would implement ``js_set`` handlers that reads cert/key from a FS or from `shared_dict`` (used as a cache here):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would implement -> implement ?

@ivanitskiy ivanitskiy requested a review from xeioex August 10, 2023 19:30
@xeioex xeioex merged commit 1fb2aa1 into nginx:master Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants