Running Nginx as Reverse Proxy server



Similar documents
How To Use Ngnix (Php) With A Php-Fpm (Php-Fmm) On A Web Server (Php5) On Your Web Browser) On An Ubuntu Web Server On A Raspberry Web 2.5 (Net

TODAY web servers become more and more

Load Balancing MODX. Garry Nutting, Senior Developer at MODX, LLC

TABLE OF CONTENTS. I. Executive Summary II. Results Overview III. Performance Testing Methodology... 5

Content. Global Delivery Network: Folders


Nginx "how to" - Fast and Secure Web Server

Content Management System

Nginx 1 Web Server Implementation Cookbook

Digital Downloads Pro

Pexip Infinity Reverse Proxy Deployment Guide

Bubble Full Page Cache for Magento

Host your websites. The process to host a single website is different from having multiple sites.

Bubble Full Page Cache for Magento

phpservermon Documentation

deploying meteor with meteor up

APACHE WEB SERVER. Andri Mirzal, PhD N

WebIOPi. Installation Walk-through Macros

How to setup HTTP & HTTPS Load balancer for Mediator

How to Configure edgebox as a Web Server

community experience distilled P U B L I S H I N G Nginx HTTP Server Clément Nedelcu Chapter No.3 "Basic Nginx Configuration"

Nginx Tricks for PHP Developers. Ilia

ultimo theme Update Guide Copyright Infortis All rights reserved

Implementing Reverse Proxy Using Squid. Prepared By Visolve Squid Team

STEP 4 : GETTING LIGHTTPD TO WORK ON YOUR SEAGATE GOFLEX SATELLITE

Secure Messaging Server Console... 2

Linux VPS with cpanel. Getting Started Guide

Nginx 1 Web Server Implementation

Expresso Quick Install

FreeBSD + nginx: Best WWW server for the best OS

IIS SECURE ACCESS FILTER 1.3

FTP, IIS, and Firewall Reference and Troubleshooting

Reference and Troubleshooting: FTP, IIS, and Firewall Information

WEB2CS INSTALLATION GUIDE

White Paper. Installation and Configuration of Fabasoft Folio IMAP Service. Fabasoft Folio 2015 Update Rollup 3

Introduction Connecting Via FTP Where do I upload my website? What to call your home page? Troubleshooting FTP...

FOR PARALLELS / PLESK PANEL

Securing the OpenAdmin Tool for Informix web server with HTTPS

Configuring MailArchiva with Insight Server

Comparison table for an idea on features and differences between most famous statistics tools (AWStats, Analog, Webalizer,...).

WEB2CS INSTALLATION GUIDE

Written by: Johan Strand, Reviewed by: Chafic Nassif, Date: Getting an ipath server running on Linux

Getting an ipath server running on Linux

Installing & Customizing the OHMS Viewer Eric Weig

SETTING UP AND RUNNING A WEB SITE ON YOUR LENOVO STORAGE DEVICE WORKING WITH WEB SERVER TOOLS

W3Perl A free logfile analyzer

ultimo theme Update Guide Copyright Infortis All rights reserved

Download/Install IDENTD

Apache 2.0 Installation Guide

Apache Usage. Apache is used to serve static and dynamic content

Deploying Intellicus Portal on IBM WebSphere

LICENSE4J LICENSE ACTIVATION AND VALIDATION PROXY SERVER USER GUIDE

(An) Optimal Drupal 7 Module Configuration for Site Performance JOE PRICE

E-Commerce: Designing And Creating An Online Store

Setup Guide Access Manager 3.2 SP3

Hadoop Data Warehouse Manual

NISHA Node Configuration and Maintenance Manual

X-POS GUIDE. v3.4 INSTALLATION SmartOSC and X-POS

Serving Media with NGINX Plus

Installation of PHP, MariaDB, and Apache

MICROSOFT OFFICE 365 MIGRATION 2013/05/13

Official Amazon Checkout Extension for Magento Commerce. Documentation

Nginx, Inc. Modules reference. NGINX Plus - release 3, based on core. March 21, 2014

Drupal CMS for marketing sites

DEPLOYMENT GUIDE Version 1.1. Deploying F5 with Oracle Application Server 10g

SVNManager Installation. Documentation. Department of Public Health Erasmus MC University Medical Center

PRODUCT VERSION: LYNC SERVER 2010, LYNC SERVER 2013, WINDOWS SERVER 2008

What is included in the ATRC server support

PROXY SETUP WITH IIS USING URL REWRITE, APPLICATION REQUEST ROUTING AND WEB FARM FRAMEWORK OR APACHE HTTP SERVER FOR EMC DOCUMENTUM EROOM

Configuring Nex-Gen Web Load Balancer

CIC Web Applications

EOP ASSIST: A Software Application for K 12 Schools and School Districts Installation Manual

Install Apache on windows 8 Create your own server

GlobalSign Solutions

CEFNS Web Hosting a Guide for CS212

Web Server Manual. Mike Burns Greg Pettyjohn Jay McCarthy November 20, 2006

SIMIAN systems. Setting up a Sitellite development environment on Windows. Sitellite Content Management System

Lesson 7 - Website Administration

Integrate Rails into an Existing IIS Web infrastructure using Mongrel

Cloud Homework instructions for AWS default instance (Red Hat based)

How to Install Multicraft on a VPS or Dedicated Server (Ubuntu bit)

Bubble Code Review for Magento

1z0-102 Q&A. DEMO Version

LAMP [Linux. Apache. MySQL. PHP] Industrial Implementations Module Description

SecuritySpy Setting Up SecuritySpy Over SSL

HOW TO CREATE THEME IN MAGENTO 2

Deploying the BIG-IP System v10 with Oracle Application Server 10g R2

The course will be run on a Linux platform, but it is suitable for all UNIX based deployments.

CTIS 256 Web Technologies II. Week # 1 Serkan GENÇ

Avatier Identity Management Suite

Installation Guide For Choic Enterprise Edition

MassTransit 6.0 Enterprise Web Configuration for Macintosh OS 10.5 Server

Computer Networks 1 (Mạng Máy Tính 1) Lectured by: Dr. Phạm Trần Vũ MEng. Nguyễn CaoĐạt

Volume SYSLOG JUNCTION. User s Guide. User s Guide

Setup a Virtual Host/Website

Installing Rails 2.3 Under Windows XP and Apache 2.2

How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu

Choic Small Business Installation Guide DigiPortal Software, Inc.

Web Development. How the Web Works 3/3/2015. Clients / Server

Transcription:

Running Nginx as Reverse Proxy server October 30 2011 This is a tutorial on running Nginx as a reverse proxy server. It covers all basics of using Nginx as a reverse proxy server. By Ayodhyanath Guru www.jafaloo.com Copyright 2011-12 @ www.jafaloo.com Page 0

Running Nginx as a Reverse Proxy Server Index 1. Introduction 2. Requirements 3. Download Nginx 4. Compile Nginx for reverse proxy 5. Configure Nginx for reverse proxy 6. Conclusion Copyright 2011-12 @ www.jafaloo.com Page 1

Introduction This is a PDF version of the tutorial how to run Nginx as a reverse proxy server. This tutorial covers all basics of running Nginx as reverse proxy server. Here I assume that you are already familiar with Linux, Nginx and shell scripting. Nginx is one of the most popular and fast web servers. Nginx can be used as a load balancer, a proxy server, a reverse proxy server, an http server, an IMAP and POP3 proxy server. Requirements Below is a list of the requirements that needs to be fulfilled before installing Nginx. You can install Nginx on Windows system also but this article is only intended for using Nginx on Linux system. 1. A Linux system 2. PCRE Library installed 3. Nginx source code 4. System should be installed with Open SSL (For SSL support) (Optional) 5. Root access to the Linux system is required. Download Nginx First of all you need to download the source code of latest stable Nginx from http://nginx.org/. The latest stable version of Nginx was 1.0.8 when this article was written. So go ahead and download the latest stable source code whichever is available. Compile Nginx for Reverse Proxy First of all you need to login to the system with root user. If PCRE library is not yet installed then install it first. After installing PCRE library, follow the below steps to compile and install Nginx as a proxy server. STEP 1: Unzip the Nginx source code that you have downloaded to the directory /usr/local/src/ STEP 2: Change the directory to Nginx home folder. Like cd nginx-1.0.8 Copyright 2011-12 @ www.jafaloo.com Page 2

STEP 3: By default Nginx will be installed in /usr/local/nginx directory. You can also change the default installation location while configuring the installation. Now from the source directory execute the below command, remember this is a single line:./configure --pid-path=/var/run/nginx.pid \ --with-http_ssl_module \ --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log Note: The line marked with red color is optional and if you do not want SSL support then you can omit that line. STEP 4: From the same source directory execute the command as shown below: make && make install This will install Nginx in the /usr/local/nginx directory. You can find the stand alone Nginx executable in the directory /us/local/nginx/sbin/. The configuration file is located at the location: /usr/local/conf/nginx.conf. Configure Nginx for Reverse Proxy By default Nginx will create a configuration file after installation. This configuration file can be used as a base file for further configuration. The below nginx.conf file is a sample one for you so that you can modify it according to your use. This sample configuration has been taken from Nginx wiki site. user www www; worker_processes 5; error_log logs/error.log; pid logs/nginx.pid; worker_rlimit_nofile 8192; events { worker_connections 4096; http { include conf/mime.types; include /etc/nginx/proxy.conf; include /etc/nginx/fastcgi.conf; index index.html index.htm index.php; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' Copyright 2011-12 @ www.jafaloo.com Page 3

'"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; sendfile on; tcp_nopush on; server_names_hash_bucket_size 128; # this seems to be required for some vhosts server { # php/fastcgi listen 80; server_name domain1.com www.domain1.com; access_log logs/domain1.access.log main; root html; location ~ \.php$ { fastcgi_pass 127.0.0.1:1025; server { # simple reverse-proxy listen 80; server_name domain2.com www.domain2.com; access_log logs/domain2.access.log main; # serve static files location ~ ^/(images javascript js css flash media static)/ { root /var/www/virtual/big.server.com/htdocs; expires 30d; # pass requests for dynamic content to rails/turbogears/zope, et al location / { proxy_pass http://127.0.0.1:8080; upstream big_server_com { server 127.0.0.3:8000 weight=5; server 127.0.0.3:8001 weight=5; server 192.168.0.1:8000; server 192.168.0.1:8001; server { # simple load balancing listen 80; server_name big.server.com; access_log logs/big.server.access.log main; Copyright 2011-12 @ www.jafaloo.com Page 4

location / { proxy_pass http://big_server_com; Now let s see the configuration for reverse proxy with cache Below http module is an example of how to configure Nginx as reverse proxy with caching: http { proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=static:10m inactive=24h max_size=1g; server { location / { proxy_pass http://1.2.3.4; proxy_set_header Host $host; proxy_cache STATIC; proxy_cache_valid 200 1d; proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504; In the above configuration we are defining the cache path with the parameter proxy_cache_path and inside the server module we are offloading the request to an http backend server with IP 1.2.3.4 (Parameter proxy_pass). With the proxy_cache parameter we are defining that Nginx should cache only static file (STATIC). With the above configuration Nginx will work as a reverse proxy server with caching enabled. For more information on different configuration options you can visit http://wiki.nginx.org. Conclusion Finally if you have any problems in installing or compiling or running Nginx as proxy server you can contact me at: jafaloo@jafaloo.com with your queries, I will try to solve them. If you need script to start, stop and restart Nginx please visit the download page @ http://www.jafaloo.com/2011/07/15/start-stop-script-for-nginx/. Note: Both the configuration examples have been taken from Nginx Wiki site. If you want to know more configuration options please visit: http://wiki.nginx.org Copyright 2011-12 @ www.jafaloo.com Page 5

Copyright 2011-12 @ www.jafaloo.com Page 6