views:

3029

answers:

2

Used to be in order to pass traffic to jboss/tomcat on port 80 using apache, we had to install and configure mod_jk. Is there an equivalent for nginx? Basically want all port 80 traffic to be passed to jboss.

+1  A: 

You don't have to use mod_jk, you can use mod_proxy, i.e. pass the traffic through over HTTP instead of AJP. If nginx has proxy ability, that should work just as well.

skaffman
The problem with a proxy is that it is slower than mod_jk/fastcgi/ajp
Adam Gent
+3  A: 

For nginx checkout their docs here. Proxy support is built in.

In the example below from their site, you will see that specific port 80 traffic is being sent to a single servlet container running on port 8080.

Note that if you want to run multiple backend servlet containers ( for load balancing, scaling, etc... ) you should look at the Upstream Fair Module that will send traffic to the least-busy backend server. It is not shipped by defaul w/nginx.

server {
  listen          80;
  server_name     YOUR_DOMAIN;
  root            /PATH/TO/YOUR/WEB/APPLICATION;
  location / {
    index.jsp;
  }
  location ~ \.do$ {
    proxy_pass              http://localhost:8080;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        Host $http_host;
  }                                                                                                       
  location ~ \.jsp$ {
    proxy_pass              http://localhost:8080;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        Host $http_host;
  }
  location ^~/servlets/* {
    proxy_pass              http://localhost:8080;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        Host $http_host;
  }
}
Ryan Cox