1. Install and Configure Apache:
Install Apache.
Code
sudo yum install httpd -y
- Configure Apache to listen on a different port (e.g., 8080) to avoid conflict with Nginx:
Code
sudo sed -i 's/^Listen 80/Listen 8080/' /etc/httpd/conf/httpd.conf
Start and enable Apache.
Code
sudo systemctl start httpd
sudo systemctl enable httpd
- Adjust firewall rules for Apache (if needed):
Code
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload
2. Install and Configure Nginx:
Install EPEL repository (required for Nginx).
Code
sudo yum install epel-release -y
install nginx.
Code
sudo yum install nginx -y
Configure Nginx as a reverse proxy.
Edit the Nginx configuration file (e.g., /etc/nginx/nginx.conf
or a new virtual host file in /etc/nginx/conf.d/
):
Code
server {
listen 80;
server_name your_domain.com; # Replace with your domain or IP
location / {
proxy_pass http://127.0.0.1:8080; # Apache's address and port
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Start and enable Nginx.
Code
sudo systemctl start nginx
sudo systemctl enable nginx
Adjust firewall rules for Nginx.
Code
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https # If using SSL/TLS
sudo firewall-cmd --reload