Install and configure nginx as a reverse proxy
1. we have to run apache in the backend and nginx in the frontend so to run both in the one server we need to change the port of apache.
Edit the httpd.conf file and find the below line and change the port number to 8080
sudo vi /etc/httpd/conf/httpd.conf
Restart Apache and validate
service httpd restart
netstat -pan | grep 8080
[Output: tcp 0 0 :::8080 :::* LISTEN 10170/httpd]
2. Install nginx
sudo yum install nginx
3. Configure nginx for apache
Create a file wordpress.conf
vi /etc/nginx/conf.d/wordpress.conf
Add the below block of code
server { listen 80; location / { proxy_pass http://127.0.0.1:8080/; #add you IP of apche server 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; } }
4. Do a configuration test
sudo service nginx configtest
5. Disable Default Host Config for Nginx
mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
6. Reload the nginx config
sudo service nginx reload