• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Reverse Proxying with Nginx : Basics

By Abhishek Ghosh February 5, 2014 7:44 pm Updated on February 5, 2014

Reverse Proxying with Nginx : Basics

Advertisement

Reverse Proxying with Nginx by Simple Editing of the File /etc/nginx/conf.d/default.conf. Reverse proxies can hide the existence and characteristics of an origin server. Few Basic Stuffs are required to be known for performing the whole work.
We think, it is better to know the basics, at least should be mentioned under separate headers by the tutorial providing websites for wider range of the readers. Unfortunately, most of the Blog websites on Technology are mainly AdSense Generated Money driven, thereby the quality of contents are becoming worser, shorter and too much keyword driven. One can expect, a tutorial on Reverse Proxying with Nginx will start with opening the default.conf file without really communicating with the reader.

 

Reverse Proxying with Nginx : Basics for the Beginners

 

We do not think that all the users searching with Reverse Proxying with Nginx has enough good knowledge on basics. It is good to have idea about SOCKS Protocol and Proxy, Proxy and Proxy Server, some idea on nginx HTTP Server.

As far with ngnix part only; we have some related tutorials like Installing nginx on Rackspace Cloud Server Video, Shifting WordPress From Apache to nginx Web Server, Installing Nginx With PHP5, MySQL on Rackspace Cloud Server, Install nginx on Rackspace Cloud Server with Centmin Mod Nginx Auto Installer or Proxy related guide – How to Use Rackspace Cloud Server as Own Proxy.

Advertisement

---

Obviously there will be readers who are more knowledgeable about ngnix administration but might not be aware about this particular topic.

The reverse proxy is a proxy, where the resources for a client of one or more servers becomes obsolete. The address translation is performed in the opposite direction, whereby the true address of the target system is hidden from the client. During a typical proxy multiple clients can be used for to an internal (private – self-contained) to an external resource to grant access; a reverse proxy works in the other way.

Reverse Proxying with Nginx

The reverse proxy initially offer the same functionality as port forwarding and so it allows to externally connect to a behind the relay server on the internal network. The reverse proxy can distribute the load across multiple servers. In web server, the reverse proxy URLs may need to be rewritten in every web page. Reverse proxies can perform A/B testing and multivariate testing without placing javascript tags or code into pages.

 

Reverse Proxying with Nginx

 

Minimum two servers are required, take that the main domain resolves example.com and the other server resolves reverse.example.com ; both points to publicly available IP addresses.

Official guide can be found here :

Vim
1
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

Ubuntu also has helpful resource :

Vim
1
https://help.ubuntu.com/community/Nginx/ReverseProxy

We will build from noarch source :

Vim
1
http://www.redhat.com/archives/shrike-list/2003-April/msg00504.html

Manually point your browser towards :

Vim
1
http://nginx.org/packages/rhel/6/noarch/RPMS/

to check if any update is available, the command below is for the current version (and you might be reading after 3 years). We need to wget it and build :

Vim
1
2
3
4
# Step 1
wget http://nginx.org/packages/rhel/6/noarch/RPMS/nginx-release-rhel-6-0.el6.ngx.noarch.rpm
# Step 2
rpm -iv nginx-release-rhel-6-0.el6.ngx.noarch.rpm

and install it :

Vim
1
yum install nginx

The configuring part is important, we are editing with command line Vim (vi) text editor, one can use nano. Open the default.conf file :

Vim
1
vi /etc/nginx/conf.d/default.conf

A typical example is provided here :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
## Basic reverse proxy server ##
## Apache (vm02) backend for www.example.com ##
upstream apachephp  {
      server 192.168.1.11:80; #Apache1
}
## Lighttpd (vm01) backend for reverse.example.com ##
upstream lighttpd  {
      server ANY_IP:80; #Lighttpd1
}
## Start example.com ##
server {
    listen       ANY_IP:80;
    server_name  example.com;
    access_log  /var/log/nginx/log/example.access.log  main;
    error_log  /var/log/nginx/log/example.error.log;
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    ## send request back to apache1 ##
    location / {
     proxy_pass  http://apachephp;
     proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
     proxy_redirect off;
     proxy_buffering off;
     proxy_set_header        Host            $host;
     proxy_set_header        X-Real-IP       $remote_addr;
     proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
   }
}
## End example.com ##
## START reverse.example.com ##
server {
   listen      OTHER_IP:80;
   server_name reverse.example.com;
   access_log  /var/log/nginx/log/reverse.example.com.access.log  main;
   error_log   /var/log/nginx/log/reverse.example.com.error.log;
   root        /usr/local/nginx/html;
   index       index.html;
   location / {
        proxy_pass  http://lighttpd;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_redirect off;
        proxy_buffering off;
        proxy_set_header        Host            reverse.example.com;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
## END reverse.example.com  ##

Configuring firewall is not described here. This part is important but is dependent on the infrastructure. On KVM virtualization, we usually open only the ports 80 and 443 on eth0 and set eth1 as trusted device.

This Article Has Been Shared 732 Times!

Facebook Twitter Pinterest
Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Orthopaedic Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Reverse Proxying with Nginx : Basics

  • Cloud Computing Privacy and how to protect Privacy in the Cloud

    Cloud Computing Privacy issues makes many administrators skeptical. Here are some tips how to avoid the security loop holes in Cloud Computing.

  • Apple Inc. and Cloud Computing

    Apple Inc. and Cloud Computing means growing and always planning to upgrade a separate from the others service, both in execution as well as by technology.

  • How to Get Started with Cloud Server

    How to Get Started with Cloud Server – be it Rackspace or Amazon or any brand which basically delivers Cloud Server as IaaS so you can allocate RAM yourself.

  • Google Compute Engine : Get Started

    Google Compute Engine has a provision to get a limited free preview after filling a survey like form. Let us look at the form as well as the technical backend.

  • Amazon Cloud Computing : Why it is a Danger to Hosting and Web Services

    Amazon Cloud Computing is a Danger to Hosting and Web Services. What must be clear is that Amazon is expanding rapidly, perhaps too much which is never good.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

You can subscribe to our Free Once a Day, Regular Newsletter by clicking the subscribe button below.

Click To Subscribe

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (20K Followers)
  • Twitter (4.9k Followers)
  • Facebook (5.8k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.2k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Arduino : Independently Blink Multiple LED January 18, 2021
  • What is a Loosely Coupled System? January 17, 2021
  • How To Repack Installed Software on Debian/Ubuntu January 16, 2021
  • Components of Agile Software Development January 15, 2021
  • What is Conway’s Law? January 14, 2021

 

About This Article

Cite this article as: Abhishek Ghosh, "Reverse Proxying with Nginx : Basics," in The Customize Windows, February 5, 2014, January 19, 2021, https://thecustomizewindows.com/2014/02/reverse-proxying-with-nginx-basics/.

Source:The Customize Windows, JiMA.in

 

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Cookie Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2021 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy