NginX : The Reverse proxy server model

By: VaibhaV Nanoti

Nginx (pronounced “EngineX”), is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. We use this as a reverse proxy server to host  a site or multiple sites proxying cache server.

We can find more details and download the RPM from http://wiki.nginx.org/Install and use nginx-release-rhel-6-0.el6.ngx.noarch.rpm  for RHEL 6.3 X86_64.

So before going for installation and configuration , the concept of reverse proxy server is elaborated by following diagram:

Installation and Configuration: We can use the same application server box or any other box to install the nginX . In this case we used the  same application server box where the Weblogic server is installed on port 7001 and managed server on port 8080.

Now install the RPM

# rpmivh nginx-release-rhel-6-0.el6.ngx.noarch.rpm

And update the /etc/nginx/nginx.conf as shown in BOLD:

Ø  Worker_processer: Decent starting point for this is the number of cores/threads on the box.
Ø  Worker_Connection: 1024 is a decent starting point but You can increase it further as per hits .

 

user  nginx;

worker_processes  2;

error_log  /var/log/nginx/error.log warn;

pid        /var/run/nginx.pid;

events {

    worker_connections  1024;

}

http {

include       /etc/nginx/mime.types;

default_type  application/octet-stream;

log_format  main  ‘$remote_addr – $remote_user [$time_local] “$request” ‘

‘$status $body_bytes_sent “$http_referer” ‘

‘”$http_user_agent” “$http_x_forwarded_for”‘;

access_log  /var/log/nginx/access.log  main;

    sendfile        on;

#tcp_nopush     on;

keepalive_timeout  65;

    gzip  on;

include /etc/nginx/conf.d/*.conf;

}

Also create the proxy. conf at same location as follows:

proxy_redirect          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;

client_max_body_size    10m;

client_body_buffer_size 128k;

proxy_connect_timeout   90;

proxy_send_timeout      90;

proxy_read_timeout      90s;

proxy_buffers           32 4k;

Now go to  /etc/nginx/conf.d

And update default.conf with below references .( Just take a backup of default. conf before updating).

## Basic reverse proxy server ##

## Weblogic (vm-DEV-12ENT) backend for enterprise12.dev.sun.net ##

server {

listen 10.10.10.100:80;

server_name enterprise12.dev.sun.net;

access_log /var/log/nginx/xamin.access.log         main;

error_log /var/log/nginx/xamin_error.log         debug;

location /Apollo

{

include proxy.conf;

proxy_pass http://10.10.10.100:8080;

}

}

server {

listen 10.10.10.100:80;

server_name vm-dev-12-cx.sun.net;

access_log /var/log/nginx/coex.access.log;

error_log /var/log/nginx/coex_error.log debug;

location /Performance {

include proxy.conf;

proxy_pass http://10.10.10.101:7015;

}

}

server {

listen 10.10.10.100:7015;

server_name vm-dev-12-cx.sun.net;

access_log /var/log/nginx/coex.access.log;

error_log /var/log/nginx/coex_error.log debug;

location /Performance {

include proxy.conf;

proxy_pass http://10.10.10.101:7015;

}

}

And at last start the nginx  server

# service nginx start

# chkconfig nginx on

# service nginx restart

We implemented the solution for  some customers ; who is not using load balancer and to improve the performance of the product.

Installation of Apache Tomcat on Linux (Red Hat).

Some terminology about Apache tomcat.

Apache Tomcat can be configured by editing server.xml file. Those who know apache web server. This server.xml can be taken as synonimas to httpd.conf file.

Servlet is defined as a way adds dynamic content to a Web server using the Java platform. And a servlet container is a compiled, executable program. The servlet container name is tomcat is Catalina.

Pre requists for Apache tomcat are
1. Java
2. JDK

Step for installing Apache tomcat

Note: avoided installing tomcat from repositories, always prefer to install it from source downloaded from apache site.

Step1: Install all the prequistes

#yum install java

Step2:Download tomcat source package and uncompressed it.
#cd /opt
#wget http://www.trieuvan.com/apache/tomcat/tomcat-6/v6.0.29/bin/apache-tomcat-6.0.29.tar.gz
#tar xvfz apache-tomcat-6.0.29.tar.gz

Step3: Setup the paths for Catalina and others.
Setting catalina path

CATALINA_HOME=/opt/apache-tomcat-6.0.29
CATALINA_BASE=/opt/apache-tomcat-6.0.29

Setting java paths

Check what java versions are installed in your system

#update-alternatives –config java

This command will display which is default java version used by your machine.

Example output:

# update-alternatives –config java

There are 2 programs which provide ‘java’.

Selection Command
———————————————–
1
/usr/lib/jvm/jre-1.4.2-gcj/bin/java
*+ 2
/usr/lib/jvm/jre-1.6.0-openjdk/bin/java

Enter to keep the current selection[+], or type selection number:

If you see above the default java version is 1.6 so set the path to /usr/lib/jvm/jre-1.6.0-openjdk

JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk
JDK_HOMe=$JAVA_HOME

Step4: Now start tomcat server

#/opt/apache-tomcat-6.0.29/bin/sartup.sh

Sample output.

Using CATALINA_BASE: /opt/apache-tomcat-5.5.26

Using CATALINA_HOME: /opt/apache-tomcat-5.5.26
Using CATALINA_TMPDIR: /opt/apache-tomcat-5.5.26/temp
Using JRE_HOME:
/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/

Step5: By default Apache Tomcat will be hosted on local host: 8080 port by default. So try to access the site with web browser

http://localhost:8080
or
http://lP:8080
or
http://systemname:8080