Configure the NGINX server
Perform the following tasks to configure the NGINX server:
In a terminal, run the following commands to set the required FXPKCS11 environment variables:
Be sure to modify the file path to match the location where libfxpkcs11.so and fxpkcs11.cfg files are stored on your system.
In a terminal, run the following command to create a new ECC key pair on the using pkcs11-tool:
The above pkcs11-tool command prompts for the user PIN. Enter the identity password configured inside the <CRYPTO-OPR-PASS> tag in the fxpkcs11.cfg file. If successful, the command output will list the keys that pkcs11-tool created on the .
In a terminal, run the following command to generate a CSR from the private key created on the for NGINX using pkcs11-tool.
The Common Name of the NGINX certificate should match the IP address or hostname of the virtual host it is configured for.
Here we are creating and using a self-signed root certificate authority (CA) for demonstration purposes. In a production environment, you should use a secure certificate authority, such as the KMES Series 3, for all private key generation and certificate signing operations.
In a terminal, run the following commands to generate a root private key and self-signed certificate. We will use this certificate to sign the NGINX certificate in the next step.
In a terminal, run the following command to issue a signed NGINX certificate using the self-signed root CA created in the previous step.
The Common Name must be the IP address or hostname of the NGINX server.
In a terminal, run the following commands to combine the NGINX and CA certificates into a single PEM file.
This section covers how to modify the configuration file for an NGINX virtual host. Configuration of a virtual host is outside the scope of this guide. Please reference the following documentation specific to your operating system if you do not already have a virtual host configured.
Before making any changes, stop your NGINX server using the following commands:
In a text editor, open the configuration file inside the conf.d/ folder in the NGINX directory for the virtual host you want to configure HTTPS for and modify it as shown below:
The location of the signed NGINX certificate specified in the ssl_certificate define needs to be modified according to where it is stored on your system. The object name of the NGINX private key specified in the ssl_certificate_key define must match the label you set in the pkcs11-tool command in a previous section.
Restart your NGINX server with the following command:
The "daemon off" startup parameter is required for this integration. Do not close the window during operation. If you receive an error message on startup, check to make sure there is not already a service running on port 443.
8 | Confirm NGINX uses the new TLS certificate and private key (stored on the ) for HTTPS connections
You can complete the following steps with the Firefox web browser. There might be some differences in the actions when using a different browser, but the overall intent of the process is the same.
In Firefox, select Settings > Privacy & Security > Certificates > View Certificates.
Select Authorities > Import and import the combined certificate (i.e., combined.pem). Use the option Trust this certificate to identity websites.
Browse to the IP address of the NGINX website that is running over HTTPS. You should see a lock icon to the left of the web address.
View the certificate that the website served to the browser and confirm it is the certificate configured for the NGINX server.