How to use Apache as Reverse Proxy using mod_proxy on Ubuntu

Published: 21 February 2023
on channel: Quickloss3
556
like

Update Server:
apt update && apt upgrade -y

Install Apache:
sudo apt install apache2

Adjusting Firewall:
sudo ufw allow 'Apache'

Enabling Necessary Apache Modules:
sudo a2enmod proxy proxy_http proxy_balancer lbmethod_byrequests
sudo systemctl restart apache2

Creating Backend Test Servers:
sudo apt install python3-pip
sudo pip3 install Flask
nano ~/backend1.py
paste
from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
return 'Hello world!'

cp ~/backend1.py ~/backend2.py
nano ~/backend2.py
update message
return 'Howdy world!'

I'm replacing angled bracket with square bracket ###

FLASK_APP=~/backend1.py flask run --port=8080 ]/dev/null 2]&1 &
FLASK_APP=~/backend2.py flask run --port=8081 ]/dev/null 2]&1 &

new terminal
curl http://127.0.0.1:8080/
curl http://127.0.0.1:8081/

Modifying the Default Configuration to Enable Reverse Proxy:
sudo nano /etc/apache2/sites-available/000-default.conf
replace with
I'm replacing angled bracket with square bracket ###
[VirtualHost *:80]
ProxyPreserveHost On

ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
[/VirtualHost]

sudo systemctl restart apache2


Watch video How to use Apache as Reverse Proxy using mod_proxy on Ubuntu online without registration, duration hours minute second in high quality. This video was added by user Quickloss3 21 February 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 556 once and liked it like people.