Thursday, December 22, 2016

Nginx Reverse Proxy To Apache Http Server

Architecture Diagram 

==========================






Summary:
========

     1) Installing Nginx
     2) Installing Apache Http Server & Integrating With Tomcat Application Server
     3) Integrating Nginx with Apache Http Server
     4) Start the Nginx Server
     5) Testing the setup Using Nginx URL.


Steps
=====

1) Installing Nginx

Download Nginx Source Files using below URL

http://nginx.org/download/nginx-1.10.1.tar.gz

OR

https://www.nginx.com/resources/wiki/start/topics/tutorials/install/

Copy the File nginx-1.10.1.tar.gz to Remote Machine 192.168.52.129 using WinSCP



Untar the File nginx-1.10.1.tar.gz using below Command.

tar -zxvf nginx-1.10.1.tar.gz

Navigate to newly create directory ie. /root/nginx/nginx-1.10.1  & Run below Commands.

For more "Installation and Compile-Time Options" Please refer below link.

https://www.nginx.com/resources/wiki/start/topics/tutorials/installoptions/

cd /root/nginx/nginx-1.10.1

./configure --with-openssl=/usr/lib64/openssl

make 

make install


Configuration summary
==================

  + using system PCRE library
  + using OpenSSL library: /usr/lib64/openssl
  + using builtin md5 code
  + sha1 library is not found
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"


2) Installing Apache Http Server & Integrating With Tomcat Application Server

Please refer below URL for this Task

https://blogbyjagan.blogspot.in/2016/12/apache-tomcat-clustering-with-apache.html


3) Integrating Nginx with Apache Http Server

Navigate to the nginx.conf location

cd /usr/local/nginx/conf

Open the file nginx.conf & add the below content for proxying requests through Apache Webserver

vi nginx.conf

        location /examples {
             proxy_set_header X-Forwarded-Host $host:$server_port;
             proxy_set_header X-Forwarded-Server $host;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_store off;
             proxy_buffering off;
             proxy_pass http://192.168.52.161;
        }




4) Start the Nginx Server

cd /usr/local/nginx/sbin

./nginx

Note: Below command is used for stopping Nginx

./nginx -s stop

5) Testing the setup Using Nginx URL.

http://192.168.52.129/examples/




1 comment: