Add SSL certificate and enable https
Add a SSL certificate to your Apache Web server reverse proxy.
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
Apache Web Server installed. Installation folder is C:\Apache24
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
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: # Secure (SSL/TLS) connections Include conf/extra/httpd-ssl.conf
Save file httpd.conf
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”
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”
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”
Save httpd-ssl.conf
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
Open the file httpd-ssl.conf (located in /conf/extra/ folder)
Locate Listen 443
Remove # infront of listen, result should look like: Listen 443
Save httpd-ssl.conf
Start Apache HTTP server
HTTPS is now enabled
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)
Open the file httpd.conf (located in /conf/ folder)
Locate Listen 80
Put a # infront of listen, result should look like: #Listen 80
Save httpd.conf
Restart Apache HTTP server
HTTP is now disabled
Last updated