Apache Configuration Guide
This guide walks you through setting up an Apache web server on Ubuntu 22.04 with:
A reverse proxy configuration where your
website.com/hashpoints tohash.yourwebsite.comHTTPS support using Let’s Encrypt via Certbot
Prerequisites
A server running Ubuntu 22.04
A registered domain name (e.g.,
yourwebsite.com)DNS A record pointing
yourwebsite.comto your server’s IP
Step 1: Install Apache Web Server
sudo apt update
sudo apt install apache2 -yStep 2: Enable Required Apache Modules
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod headers
sudo a2enmod rewriteRestart Apache to apply changes:
sudo systemctl restart apache2Step 3: Configure Apache Virtual Host for site.com
Create a new site configuration file:
sudo nano /etc/apache2/sites-available/yourwebsite.com.confPaste the following content:
<VirtualHost *:80>
    ServerName yourwebsite.com
    DocumentRoot /var/www/html
    SSLProxyEngine On
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    ProxyPreserveHost Off
        <Proxy *>
           Require all granted
        </Proxy>
    ProxyPass /hash http://hash.yoursite.com
    ProxyPassReverse /hash http://hash.yoursite.com/
    ErrorLog ${APACHE_LOG_DIR}/yoursite.com_error.log
    CustomLog ${APACHE_LOG_DIR}/yoursite.com_access.log combined
</VirtualHost>Enable the new site and disable the default:
sudo a2ensite site.com.conf
sudo a2dissite 000-default.conf
sudo systemctl reload apache2Step 4: Install Certbot and Apache Plugin
sudo apt install certbot python3-certbot-apache -yStep 5: Obtain SSL Certificate with Certbot
sudo certbot --apache -d yourwebsite.comCertbot will:
Automatically configure HTTPS in Apache
Enable HTTP to HTTPS redirection
Reload Apache automatically
Step 6: (Optional) Test Auto-Renewal
Verify Certbot renewal service:
sudo systemctl list-timers | grep certbotSimulate a dry run renewal:
sudo certbot renew --dry-runStep 7: Verify Setup
Test the proxy by visiting:
https://yourwebsite.com/hashIt should forward the request to:
http://hash.yourwebsite.com/Conclusion
You now have:
Apache running on Ubuntu 22.04
HTTPS enabled via Let’s Encrypt
A reverse proxy from
yourwebsite.com/hashtohash.yourwebsite.com
If you have any questions or feedback, please open a request on our Helpdesk.
Last updated
Was this helpful?