Accept HTTPS Self Certificate on Local via Apache2
When you’re working on a local development environment and need to accept self-signed HTTPS certificates through Apache2, you can use the following configuration in your virtual host file. This setup allows you to bypass certificate verification for local testing purposes.
Assuming you already have a virtual host set up in your Apache2 configuration, here are the steps to configure it to accept self-signed HTTPS certificates:
-
Enable the
proxy
andproxy_http
modules:Before configuring the SSL proxy, make sure the required modules are enabled. You can do this using the
a2enmod
command.1 2
sudo a2enmod proxy sudo a2enmod proxy_http
-
Edit your Virtual Host Configuration:
Open your virtual host configuration file. This is typically located in the
/etc/apache2/sites-available/
directory and has a.conf
extension, e.g.,your-site.conf
.1
sudo nano /etc/apache2/sites-available/your-site.conf
Inside your virtual host configuration, add or modify the following lines to enable the SSL proxy settings:
1 2 3 4 5 6 7 8 9 10 11 12 13
<VirtualHost *:80> # ... Other Virtual Host Settings ... # Enable SSL Proxy SSLProxyEngine on SSLProxyVerify none SSLProxyCheckPeerCN off SSLProxyCheckPeerName off SSLProxyCheckPeerExpire off ProxyPass / https://localhost:443/ ProxyPassReverse / https://localhost:443/ </VirtualHost>
Ensure that you replace
your-site.conf
with the actual filename of your virtual host configuration and adjust theProxyPass
andProxyPassReverse
directives to match your specific setup. -
Save and Exit:
Save the changes to your configuration file and exit the text editor.
-
Enable the Virtual Host:
Enable your virtual host configuration if it’s not already enabled:
1
sudo a2ensite your-site.conf
-
Restart Apache:
Restart Apache to apply the changes:
1
sudo systemctl restart apache2
Now, your Apache2 server should accept self-signed HTTPS certificates for the specified virtual host. Be cautious when using these settings in a production environment, as they disable important security checks. These settings are primarily for local development and debugging purposes.