Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| linux:installation:openssl [2022/09/03 14:53] – [Creating an Apache Configuration Snippet with Strong Encryption Settings] tutospisto | linux:installation:openssl [2022/09/03 14:58] (Version actuelle) – [Step 5 — Testing Encryption] tutospisto | ||
|---|---|---|---|
| Ligne 162: | Ligne 162: | ||
| . . . | . . . | ||
| </ | </ | ||
| + | |||
| + | |||
| + | |||
| + | Save and close the file when you are finished. | ||
| + | |||
| + | That’s all of the configuration changes you need to make to Apache. Next, we will discuss how to update firewall rules with ufw to allow encrypted HTTPS traffic to your server. | ||
| + | ===== Step 3 — Adjusting the Firewall ===== | ||
| + | |||
| + | Je n’ai pas réalisé cette étape. | ||
| + | |||
| + | ===== Step 4 — Enabling the Changes in Apache ===== | ||
| + | |||
| + | Now that we’ve made our changes and adjusted our firewall, we can enable the SSL and headers modules in Apache, enable our SSL-ready Virtual Host, and then restart Apache to put these changes into effect. | ||
| + | |||
| + | Enable mod_ssl, the Apache SSL module, and mod_headers, | ||
| + | |||
| + | <code bash> | ||
| + | sudo a2enmod ssl | ||
| + | sudo a2enmod headers | ||
| + | sudo a2ensite default-ssl | ||
| + | sudo a2enconf ssl-params | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | At this point, the site and the necessary modules are enabled. We should check to make sure that there are no syntax errors in our files. Do this by typing: | ||
| + | <code bash> | ||
| + | |||
| + | |||
| + | |||
| + | If everything is successful, you will get a result that looks like this: | ||
| + | |||
| + | <code bash> | ||
| + | Syntax OK</ | ||
| + | |||
| + | |||
| + | As long as your output has Syntax OK in it, then your configuration file has no syntax errors and you can safely restart Apache to implement the changes: | ||
| + | |||
| + | <code bash> | ||
| + | |||
| + | |||
| + | With that, your self-signed SSL certificate is all set. You can now test that your server is correctly encrypting its traffic. | ||
| + | |||
| + | |||
| + | ===== Step 5 — Testing Encryption ===== | ||
| + | |||
| + | |||
| + | You’re now ready to test your SSL server. | ||
| + | |||
| + | Open your web browser and type <code bash> | ||
| + | |||
| + | <code bash> | ||
| + | |||
| + | Because the certificate you created isn’t signed by one of your browser’s trusted certificate authorities, | ||
| + | |||
| + | You should be taken to your site. If you look in the browser address bar, you will see a lock with an « x » over it or another similar “not secure” notice. In this case, this just means that the certificate cannot be validated. It is still encrypting your connection. | ||
| + | |||
| + | If you configured Apache to redirect HTTP to HTTPS, you can also check whether the redirect functions correctly: | ||
| + | |||
| + | <code bash> | ||
| + | |||
| + | If this results in the same icon, this means that your redirect worked correctly. However, the redirect you created earlier is only a temporary redirect. If you’d like to make the redirection to HTTPS permanent, continue on to the final step. | ||
| + | ===== Step 6 — Changing to a Permanent Redirect ===== | ||
| + | |||
| + | |||
| + | If your redirect worked correctly and you are sure you want to allow only encrypted traffic, you should modify the unencrypted Apache Virtual Host again to make the redirect permanent. | ||
| + | |||
| + | Open your server block configuration file again: | ||
| + | <code bash> | ||
| + | |||
| + | Find the Redirect line we added earlier. Add permanent to that line, which changes the redirect from a 302 temporary redirect to a 301 permanent redirect: | ||
| + | |||
| + | **/ | ||
| + | <code bash>< | ||
| + | . . . | ||
| + | |||
| + | Redirect permanent "/" | ||
| + | |||
| + | . . . | ||
| + | </ | ||
| + | |||
| + | Save and close the file. | ||
| + | |||
| + | Check your configuration for syntax errors: | ||
| + | <code bash> | ||
| + | |||
| + | If this command doesn’t report any syntax errors, restart Apache: | ||
| + | <code bash> | ||
| + | |||
| + | This will make the redirect permanent, and your site will only serve traffic over HTTPS. | ||
| + | |||