
Apache is a web server application that can serve dynamic web content or act as a reverse proxy —forwarding client requests to back-end applications. This article explains how to configure Apache as a reverse proxy with mod_proxy.
This guide proxies an ownCloud application on port 8080 under Docker, but you can use the same technique to host another application on a different port.
Deploy a fresh Vultr Cloud Server.
A Ubuntu 20.04 server is used in this article, but these instructions work for any Linux server running Apache.
Set up a DNS "A" record pointing to the server's IP address. This guide uses the name app.example.com.
Connect to the server.
Log in as a non-root user with sudo privileges.
Install Apache.
Install Docker.
Enable the Apache mod_proxy module.
Enable additional modules.
Here is what each module does:
mod_proxy: Implements proxying on the Apache server.proxy_http: Handles proxy HTTP and HTTPS requests.proxy_balancer: Enables load balancing.proxy_wstunnel: Tunnels web socket connections to a back-end server.Restart Apache to activate modules.
As an example, set up an ownCloud container listening on port 8080 under Docker.
Create the ownCloud docker container.
Start ownCloud.
Verify that ownCloud is running.
Output:
Back up the default Apache virtual host configuration file.
Create a new configuration file.
Add the following contents to the file. Change app.example.com to your server name. If you are setting up a proxy for a different app than the ownCloud example, you may need to update port 8080 to your application's port number in the file below.
Save and close the file.
Here is what each directive means:
ProxyPreserveHost: Forwards the original host header to the back-end application.ProxyPass: Specifies that all requests / are forwarded to the back-end application port.ProxyPassReverse: Negates ProxyPass by modifying response headers from the back-end application.Activate the configuration file.
Test the Apache configuration for errors.
Restart Apache to load changes.
Configure the firewall to allow HTTP traffic on port 80.
Allow HTTPS on port 443.
Restart the firewall.
Install Certbot.
Request a Let's Encrypt SSL Certificate.
Test Auto-renewal.
Open a web browser, and visit your subdomain.
The ownCloud login page should be displayed. Log in with the username admin, and password admin to start using the application.
You have configured Apache as a reverse proxy and set up ownCloud as the back-end application. For further information, refer to the following resources.
0 Comments
Be the first to comment and share your perspective with the community.