Universal Messaging server behind NGINX
Tags: webmethods, universalmessagingbroker
Published: 2022-07-01 09:45:02

---
title: Universal Messaging server behind NGINX
published: true
date: 2022-06-16 07:08:36 UTC
tags: webMethods, UniversalMessagingBroker
canonical_url: https://tech.forums.softwareag.com/t/universal-messaging-server-behind-nginx/258338
---


## Universal Messaging server behind NGINX Product Versions: Universal Messaging & IS from 10.5 fix 8 onwards

## Introduction

**NGINX AS PROXY SERVER FOR UM**

This section covers the NGINX configuration for serving UM http requests and its detailed description.

To begin with, let’s consider a very basic setup where we expose a NGINX server port which is configured on um server settings. Clients who want to connect will be making requests to the NGINX server instead of UM directly. NGINX server takes care of redirection to the UM server

Below are the configuration that one needs to consider while configuring UM behind load bealnacer.

```
	events {
	worker_connections 1024;
}
http {
	default_type application/octet-stream;  
    #Log Settings
	log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

	#create logs directory in /etc/nginx path before configuring these otherwise you can use default directory #path /var/log/nginx to configure error and access logs
	access_log logs/access.log;
	error_log logs/error.log warn;

	# Server will close idle connection after this timeout.
    keepalive_timeout 300s;

	# number of requests client can make over single connection.
	keepalive_requests 1000000;

	# This is a must, since UM client is currently sending: User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; #Windows NT 5.0) and default 'msie6' matches this and causes nginx to close UM client connections
	keepalive_disable none;

    upstream umbackend {
		server localhost:11000;

		# maximum number of keep alive connections to maintain to each upstream server
		keepalive 100;
		# Server will close idle connection after this timeout.
        keepalive_timeout 300s;

		# number of requests client can make over single connection.
		keepalive_requests 1000000;		
	}
      
server {
    	listen 80;
		server_name loadbalancer;
		# Important - nginx must continuously send data to UM client rather than buffering it
		proxy_buffering off;

		location / {
			proxy_pass http://umbackend;
			#Important - configure proxy http 1.1 protocol version to enable connection      
            #keep-alive and rewrite Connection header
            proxy_http_version 1.1;
			proxy_set_header Connection "";		
          }
     }

```

}

## Required UM Configurations Details

| **Directives** | **Required Value** | **Explanation** |
| --- | --- | --- |
| proxy\_buffering | _Off_ | Default Value : on : This must be disabled for serving UM requests as UM does not send a content length to initial HTTP connections [see [specification](https://www.w3.org/Protocols/HTTP/1.0/draft-ietf-http-spec.html#BodyLength)] as it uses it for a long lived persistent connection from a UM server to a UM client. This option optimises for stateless http environments however UM uses a streaming protocol. |
| proxy\_pass | Example: [http://umhost](http://umhost):port | Proxied UM server’s URL, UM should either be configured with nhp/nhps protocol. Proxy\_pass would take http or https protocol accordingly to redirect the requests. |
| access\_log | **logs/access.log** | You must create a logs directory inside /etc/nginx folder before starting the nginx or you can you the default log directory which is locate at /var/log/nginx. Client information will be written in the access log and by default access log will be written to a directory \*\*logs/access.log,\*\*You can override it by adding access\_log directive with path of your choice. |
| error\_log | **logs/error.log** | writes information about encountered issues of different severity levels to the error log. By default, the error log is located at **logs/error.log** |
| keepalive | 100 | Keepalive settings are important whenever upstream server need to handle high number of connections with the clients.Keepalive number\_of \_Idle connection that upstream server can have.This is allowed in upstream directive for proxied server. |
| keepalive\_requests | 100000 | Number of requests that can be served through one keepalive connection to an upstream server.[keep this a high value] |
| keepalive\_ timeout | 300s | This sets a timeout to an idle connection that remains open for specified amount of time . Default time is 75seconds. |
| proxy\_http\_version | 1.1 | By default, nginx will have http version 1.0 which need to be overridden with http 1.1 version. |
| proxy\_set\_header | connection “” | And this directive used to set the headers, by default nginx sets connection header to close, due to which upstream server’s connections will closed by the nginx server. Hence this need to be set with empty value. |

## Load the configuration and start the nginx server

If you want to test on your NGINX set-up for your UM server, use the above configuration. Update proxy\_pass with your running UM server’s HTTP Interface and update this in your /etc/nginx/nginx.conf file and start the server.

In the above configuration serves static files over HTTP on port 80 from the directory / _opt/softwareag/UniversalMessaging/doc/ [opt/softwareag is installation directory, you can configure to serve your own static file as well.]_

> nginx -s reload

Use the reload method of NGINX to achieve a graceful reload of the configuration without stopping the server  
All the requests from clients which contains um1 in its URL segment, are forwarded to the proxied server which is defined in umbackend upstream.i.e umserver which is running locally on port 11000

## **Sample-Program to validate**

Check out the [full post](https://tech.forums.softwareag.com/t/universal-messaging-server-behind-nginx/258338) in the Software AG Tech Community the to see the Sample-program to validate.

## **Things to consider if there are dedicated servers configured based on the URL pattern**
for example:

 server {
listen 80;
server_name loadbalancer;
proxy_buffering off;
location = / umserver1 {
proxy_pass http://um1;
proxy_http_version 1.1;
proxy_set_header Connection “”;
}
location = /umserver2 {
proxy_pass http://um2;
proxy_http_version 1.1;
proxy_set_header Connection “”;
}
location = /umserver3 {
proxy_pass http://um3;
proxy_http_version 1.1;
proxy_set_header Connection “”;
}
}

As you can see , if you have set the directive location with the some specific pattern
one has to use url as follows to connect to nginx
i.e nhp://nginxhost:nginxport/umserver1, nhp://nginxhost:nginxport/umserver2, nhp://nginxhost:nginxport/umserver3

but if you are using the client below the version below 10.5 you must have to use the URL with extra slash in order to work. i.e
nhp://nginxhost:nginxport//umserver1, nhp://nginxhost:nginxport//umserver2, nhp://nginxhost:nginxport//umserver3

For more details such as configuring with secured socket layer please visit the [original post](https://tech.forums.softwareag.com/t/universal-messaging-server-behind-nginx/258338) in the Software AG Tech Community where you will find a document on
Configuring UM behind NGINX Server (part 2).