2. Add certificate and enable https
Add a SSL certificate to your Apache Web server reverse proxy.
Scenario
Section titled “Scenario”You have installed Apache Web Server and it works on port 80. Now you like to add a certificate so the service also works on port 443 and also maybe disable access on port 80.
This is a generic use case, however I will use a Windows server in the use case to explain setup.
Prerequisite
Section titled “Prerequisite”- Apache Web Server installed. Installation folder is C:\Apache24
Create a certificate to use for https communication
Section titled “Create a certificate to use for https communication”Different kinds of certificate types are supported. In this scenario I will use a *.pem file. Either you create a self-signed certificate or purchase a real certificate.
Note. You can also create a real certificate (trusted by the browsers) by using e.g. https://www.win-acme.com/. In this scenario you can in your DNS point to your test server and make it work in a real live scenario.
Take the certificate files and put them in a folder. I have created a folder called \certificates, see full file path, C:\Apache24\conf\extra\certificates
Enable HTTPD-SSL configuration
Section titled “Enable HTTPD-SSL configuration”You enable httpd-ssl configuration by including the configuration file in httpd.conf file. That file will include configuration for https (443).
- Open file httpd.conf C:\Apache24\conf
- Locate following lines and remove comment for httpd-ssl.conf.
Correct configuration should look like follows:
&#xNAN;# Secure (SSL/TLS) connections
&#xNAN;Include conf/extra/httpd-ssl.conf - Save file httpd.conf
Add references to your certificate
Section titled “Add references to your certificate”- Open the file httpd-ssl.conf (located in /conf/extra/ folder)
- Find line SSLCertificateFile and add your certificate. Remove # to enable the configuration line.
- For example used with my certificate
SSLCertificateFile “C:\Apache24\conf\extra\certificates\dev.fortifiedid.se-crt.pem”
- For example used with my certificate
- Find line SSLCertificateKeyFile and add your key file. Remove # to enable the configuration line.
- For example used with my key file. Remove # to enable the configuration line.
SSLCertificateKeyFile “C:\Apache24\conf\extra\certificates\dev.fortifiedid.se-key.pem”
- For example used with my key file. Remove # to enable the configuration line.
- Find line SSLCertificateChainFile and add your chain file. Remove # to enable the configuration line.
This parameter is optional. Should NOT be used if no intermediate CA certificate is used or if your certificate is self-signed.- For example used with my chain file. Remove # to enable the configuration line.
SSLCertificateChainFile “C:\Apache24\conf\extra\certificates\dev.fortifiedid.se-chain-only.pem”
- For example used with my chain file. Remove # to enable the configuration line.
- Save httpd-ssl.conf
Add mandatory modules for https
Section titled “Add mandatory modules for https”- Open the file httpd.conf (located in /conf/extra/ folder)
- Find and enable following modules. You enable by removing the # character.
- LoadModule proxy_module modules/mod_proxy.so
- LoadModule proxy_connect_module modules/mod_proxy_connect.so
- LoadModule proxy_http_module modules/mod_proxy_http.so
- LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
- LoadModule ssl_module modules/mod_ssl.so
- Save httpd-ssl.conf
Enable https protocol
Section titled “Enable https protocol”- Open the file httpd-ssl.conf (located in /conf/extra/ folder)
- Locate Listen 443
- Remove # in front of listen, result should look like:
Listen 443 - Save httpd-ssl.conf
- Start Apache HTTP server
- HTTPS is now enabled
Verify https
Section titled “Verify https”- Open a browser
- Browse to for https://localhost/
- You should be prompted with:
It works! - If this will not work you might need to check local firewall on windows server.
Disable http (optional)
Section titled “Disable http (optional)”- Open the file httpd.conf (located in /conf/ folder)
- Locate Listen 80
- Put a # in front of listen, result should look like:
#Listen 80 - Save httpd.conf
- Restart Apache HTTP server
- HTTP is now disabled