• 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 547 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, 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

Get new posts by email:

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 (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Online Dating: How to Find Your Match March 20, 2023
  • Web Design Cookbook: Logo March 19, 2023
  • How Starlink Internet Works March 17, 2023
  • The Importance of a Camera Tracking System in Virtual Production March 15, 2023
  • Understanding the Key Differences between Docker and OpenVZ March 14, 2023

About This Article

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

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

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

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

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

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT