NGINX as razuna AJP frontend

As nginx has ajp module implemented I suggest my configuration for those who are interested. This was used to add SSL frontend to intranet Razuna working with http, but soon this config was found to work faster, than http frontend suggested at razuna wiki page.


user nginx nginx;
worker_processes 2;

error_log /var/log/nginx/error_log info;

events {
worker_connections 1024;
use epoll;
}

http {

    upstream tomcats {
            server 127.0.0.1:8009;
            keepalive 10;
            }

            ajp_keep_conn on;
            ajp_pass_request_body on;
            ajp_pass_request_headers on;
            ajp_max_temp_file_size 0;
            ajp_cache       off;
            client_max_body_size 0;
            ajp_store       off;
            ajp_connect_timeout     120;
            ajp_send_timeout        1200;


   server {
            listen          80 default;
            server_name     dam.mydo.main;

            access_log /var/log/nginx/localhost.http_access_log main;
            error_log /var/log/nginx/localhost.http_error_log info;

            root            /path-to-tomcat/webapps/razuna;

            location /assets {

# This is used for /assets not to be processed in any other section
root /path-to-tomcat/webapps/razuna;
}

            location = / {

#This is “bootstrap” section to make first coming user get index.cfm

                           rewrite  ^(.*)$ /index.cfm break;
                            ajp_pass tomcats;
            }

            location / {

# ajp_pass tomcats; This is intentionally commented : post requests go directly with lines below, all CFM-containing URLs are caught with CFM section and all other files (pictures, JS, css etc) are served here with nginx, not tomcat.

                       # All POST requests go directly
                        if ($request_method = POST) {
                                                    ajp_pass tomcats;
                                                     break;
                                                   }
                        }
              location ~ \.cfm$ {
                                ajp_pass tomcats;
                                }

             }

}
}

This is great.

However, some over at Tomcat and Java “gurus” say that AJP is not faster than the standard HTTP one. Also, in order to run this you need to install the native drivers of Tomcat.

The configuration can be further tuned so that you can have more worker_processes and also 1024 worker_connections per core in nginx. Furthermore, you could add caching to it.

Just some suggestions.

Can you please post the whole config, so it is not copped up with comments. This would make it easier to read, since it looks like you have embedded locations in there.

Thanks. Your contribution is much appreciated.

On Sun, Dec 14, 2014 at 10:08 AM, zdv770 <help@razuna.com> wrote:


zdv777

December 14

As nginx has ajp module implemented I suggest my configuration for those who are interested. This was used to add SSL frontend to intranet Razuna working with http, but soon this config was found to work faster, than http frontend suggested at razuna wiki page.


user nginx nginx;

worker_processes 2;

error_log /var/log/nginx/error_log info;

events {

    worker_connections 1024;

    use epoll;

}

http {

    upstream tomcats {
            server 127.0.0.1:8009;
            keepalive 10;
            }

            ajp_keep_conn on;
            ajp_pass_request_body on;
            ajp_pass_request_headers on;
            ajp_max_temp_file_size 0;
            ajp_cache       off;
            client_max_body_size 0;
            ajp_store       off;
            ajp_connect_timeout     120;
            ajp_send_timeout        1200;


   server {
            listen          80 default;
            server_name     dam.mydo.main;

            access_log /var/log/nginx/localhost.http_access_log main;
            error_log /var/log/nginx/localhost.http_error_log info;

            root            /path-to-tomcat/webapps/razuna;

            location /assets {

# This is used for /assets not to be processed in any other section

                            root            /path-to-tomcat/webapps/razuna;

            }</p>
            location = / {

#This is "bootstrap" section to make first coming user get index.cfm

                           rewrite  ^(.*)$ /index.cfm break;
                            ajp_pass tomcats;
            }

            location / {

# ajp_pass tomcats; This is intentionally commented : post requests go directly with lines below, all CFM-containing URLs are caught with CFM section and all other files (pictures, JS, css etc) are served here with nginx, not tomcat.

                       # All POST requests go directly
                        if ($request_method = POST) {
                                                    ajp_pass tomcats;
                                                     break;
                                                   }
                        }
              location ~ \.cfm$ {
                                ajp_pass tomcats;
                                }

             }

}

}


To respond, reply to this email or visit http://help.razuna.com/t/nginx-as-razuna-ajp-frontend/245/1 in your browser.

To unsubscribe from these emails, visit your user preferences.

Hi, you can get config here
Yes, this requires native lib and works just fine.

Do all the latest versions of NGINX have AJP built in, or do we have to compile / install something on our NGINX to be able to use AJP?

Distribution I use (Gentoo) has plugin as configurable option at install. I think most distros should have it as it’s nothing new now.