To configure SSL/TLS with Nginx on CentOS, you can follow these steps:
Step 1: Install Nginx
If you haven't installed Nginx, run the following command to install it:
Step 2: Install OpenSSL
If you don't have OpenSSL installed, install it using the following command:
Step 3: Create a directory for SSL certificate files
Create a directory to store SSL certificate files:
Step 4: Generate self-signed SSL/TLS certificates (Optional)
If you are not using SSL certificates from a certificate authority, you can generate self-signed certificates with OpenSSL. This is useful for testing SSL/TLS in a development environment. To create a self-signed certificate, run the following commands:
Step 5: Configure Nginx to use SSL/TLS
Open the Nginx configuration file for the website you want to secure:
Add the following lines to the configuration file to enable SSL:
Step 6: Test and restart Nginx
Check if the Nginx configuration has any errors:
If there are no errors, restart the Nginx service to apply the new configuration:
Once completed, your website will be secured with SSL/TLS. Note that using self-signed certificates will result in the browser warning about untrusted certificates. To have a trusted SSL/TLS certificate, you need to purchase or obtain a free certificate from a certificate authority.