Skip to content

Instantly share code, notes, and snippets.

@AbdullahGhani1
Last active November 23, 2022 17:48
Show Gist options
  • Save AbdullahGhani1/cf2a1e98cd02143fb10785d31b049818 to your computer and use it in GitHub Desktop.
Save AbdullahGhani1/cf2a1e98cd02143fb10785d31b049818 to your computer and use it in GitHub Desktop.
Linux Nginx as Reverse Proxy -Kodekloud

Linux Nginx as Reverse Proxy

Nautilus system admin's team is planning to deploy a front end application for their backup utility on Nautilus Backup Server, so that they can manage the backups of different websites from a graphical user interface. They have shared requirements to set up the same; please accomplish the tasks as per detail given below:

a. Install Apache Server on Nautilus Backup Server and configure it to use 8087 port (do not bind it to 127.0.0.1 only, keep it default i.e let Apache listen on server's IP, hostname, localhost, 127.0.0.1 etc).

b. Install Nginx webserver on Nautilus Backup Server and configure it to use 8092.

c. Configure Nginx as a reverse proxy server for Apache.

d. There is a sample index file /home/index.html on Jump Host, copy that file to Apache's document root.

e. Make sure to start Apache and Nginx services.

f. You can test final changes using curl command, e.g curl http://:8092.

==========

Click on ✔ and Do Task Again

Solution:

ssh clint@stbkp01

Then install httpd and nginx by running following commands
sudo yum install -y httpd
sudo yum install -y epel-release 
sudo yum install -y nginx
Now ,edit the apache config file and Change port
and ServerName according to question
sudo vi  /etc/httpd/conf/httpd.conf
Listen 6000
#Go to ServerName and uncomment by removing # and write 172.16.238.16:6000
ServerName 172.16.238.16:6000
Now save the config and restart httpd and Go to nginx config by typing
sudo systemctl enable httpd
sudo systemctl restart httpd
sudo vi /etc/nginx/nginx.conf
Edit the config as follows.
For reverse proxy add the proxy_pass in location tab
like this config image.

image

Save it and restart nginx Now,
sudo systemctl restart nginx

Go to jump host and copy index.html file

scp /home/index.html clint@stbkp01:/tmp
Now switch to backup server and copy it to httpd document root
sudo cp /tmp/index.html /var/www/html
Finally move to jump_host and check
curl  http://172.16.238.16:8095
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment