Benefits of using nginx as a reverse proxy

iot
Success Story / Tips

Benefits of using nginx as a reverse proxy

NGINX is 2.5 time faster than Apache based on the benchmark test running up to 1,000 concurrent connections. Apache benchmark running with 512 concurrent connections, For a static content NGINX is king when come to dynamic content apache will be doing slightly better job than nginx, this is many reason for using nginx as reverse for proxy to apache. 

Increased Security:  Reverse proxy also act as a defense for backend server, configuring your reverse proxy makes your backend server unknown.

Better Performance: As known nginx servers static content better than apache, With the nginx proxy all the static content will be handled by nginx meanwhile request for dynamic content can be. Passed on the backend server, This improves performance by optimizing the delivery of assets based on their type,

How to install and configure on ubuntu 16.04

sudo apt-get install apache2
sudo nano /etc/apache2/ports.conf
change listen port 80 to 8080

sudo nano /etc/apache2/sites-available/000-default.conf
change to sudo service apache2 reload

check apache listen on port 8080 by below command sudo netstat -tlpn

Install Nginix

sudo apt-get install nginx
Remove default site
sudo rm /etc/nginx/sites-enabled/default

configure site directory sudo mkdir -v /usr/share/nginx/{example.com,sample.org}

create proxy site for apache2 sudo nano /etc/nginx/sites-available/{example.com,sample.org}

server {
listen 80;
server_name example.com www.example.com; # replace with your site’s
location / {
proxy_pass http://localhost:8080;
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;
}
}

Enable your site, sudo ln -s /etc/nginx/sites-available/{example.com,sample.org} /etc/nginx/sitesenabled/{example.com,sample.org}sudo

Test configuration
service nginx configtest

Restart the nginx
sudo service nginx reload

Reference Link

 

Privacy Overview
Logo

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

Additional Cookies

This website uses the following additional cookies:

(List the cookies that you are using on the website here.)