Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Nginx as a Revers Proxy for Apache on Ubuntu
1. Subject: Nginx as a Reverse Proxy for Apache
Presented by: Abdullah Roomi
Presented to : MSc. amjad alhouseini
HEBRON UNIVERSITY
COLLEGE: INFORMATION TECHNOLOGY
DEPARTMENT: SECURITY AND PROTECTION OF COMPUTER
NETWORKS
2. OBJECTIVES
• Why Run Nginx and Apache Together
• Install nginx
• Configure nginx
• Install Apache
• Configure Apache
• Apache2 files
3. WHY RUN NGINX AND APACHE TOGETHER
• apache’s power and nginx’s speed are well known.
However, both servers do have drawbacks—apache is
hard on server memory, while nginx (great at static
files) needs the help of php-fpm or similar modules for
dynamic content.
4. INSTALL NGINX
• To start off, we need to install and configure nginx
which will serve the front end of our site. Let’s
download it from apt-get:
Sudo apt-get install nginx
6. CONFIGURE NGINX (CONT’D)
The following changes were implemented in the configuration:
• The root was set to the correct web directory
• index.php was added on the index line
• try_files attempts to serve whatever page the visitor requests. If nginx
is unable, then the file is passed to the proxy
• proxy_pass lets nginx the address of the proxied server
• Finally the "location ~ /.ht {" location block denies access to .htaccess
files, if Apache's document root concurs with nginx's one
This configuration sets up a system where all extensions with a php
ending are rerouted to the apache backend which will run on port 8080.
7. CONFIGURE NGINX (CONT’D)
• Activate the virtual host.
sudo ln -s /etc/nginx/sites-available/example
/etc/nginx/sites-enabled/example
• Additionally, delete the default nginx server block.
sudo rm /etc/nginx/sites-enabled/default
8. INSTALL APACHE
• With nginx taken care of, it’s time to install our backend, apache.
Sudo apt-get install apache2
9. CONFIGURE APACHE
• We need to configure apache to take over the backend,
which as we told nginx, will be running on port 8080.
Open up the apache ports file to start setting apache on
the correct port:
sudo nano /etc/apache2/ports.conf
10. CONFIGURE APACHE (CONT’D)
• Find and change the following lines to have apache
running on port 8080, accessible only from the
localhost:
• Save and Exit.
NameVirtualHost 127.0.0.1:8080
Listen 127.0.0.1:8080
11. CONFIGURE APACHE (CONT’D)
• Subsequently, open up a new virtual host file,
copying the layout from the default apache file
• The line should look like this:
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-
available/example.conf
sudo nano /etc/apache2/sites-available/example
<VirtualHost 127.0.0.1:8080>
12. CONFIGURE APACHE (CONT’D)
• Make sure your Document Root is correct. Save and
exit the file and activate that virtual host:
sudo a2ensite example.conf
13. CONFIGURE APACHE (CONT’D)
• Before we start testing anything out, we need to equip
apache with php. Go ahead and install it now:
sudo apt install php libapache2-mod-php
sudo apt install php-mysql
sudo apt install php-pgsql
14. CONFIGURE APACHE (CONT’D)
• Restart both servers to make the changes effective:
sudo service apache2 restart
sudo service nginx restart
17. REFERENCES
• Nginx as a Reverse Proxy for Apache
• https://www.digitalocean.com/community/tutorials/how-
to-configure-nginx-as-a-reverse-proxy-for-apache
• How to install php and mysql
• https://help.ubuntu.com/lts/serverguide/php.html