This section provides setup instructions for configuring a load balancer for Zephyr Enterprise Data Center. Any load balancer can be configured to work, however we recommend using NGINX. Below you will find a guide on setting up a NGINX load balancer with Zephyr Enterprise Data Center.
Before you begin
- Review all system requirements thoroughly
Ngnix Setup on Windows
Step 1:
Download the Nginx archive file from here
Step 2:
In the conf folder, find the file named nginx.conf and modify the http section to contain the following:
upstream tomcat_servers{ server node1:8080; server node2:8080; } location /flex/ { #for web socket and long-polling in nginx proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_buffering off; proxy_ignore_client_abort off; #for tomcat proxy proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_pass ; } location ~* \.(js|jpg|png|css)$ { root <path to webapps>; expires 1d; #proxy_set_header Host $http_host; #proxy_set_header X-Real-IP $remote_addr; #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_pass http://tomcat/; }
Add a separate section within the http section:
map $http_upgrade $connection_upgrade { default Upgrade; '' close; }
Ngnix Setup on Linux
Step 1:
sudo apt-get install nginx
Step 2:
Edit /etc/nginx/nginx.conf or /etc/nginx/sites-available/default (if present) and add to the http section:
upstream tomcat_servers{ server node1:8080; server node2:8080; } location /flex/ { #for web socket and long-polling in nginx proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_buffering off; proxy_ignore_client_abort off; #for tomcat proxy proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_pass ; } location ~* \.(js|jpg|png|css)$ { root <path to webapps>; expires 1d; #proxy_set_header Host $http_host; #proxy_set_header X-Real-IP $remote_addr; #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_pass http://tomcat/; }
Add a separate section with the http section:
map $http_upgrade $connection_upgrade { default Upgrade; '' close; }
Sample Nginx.conf file:
Configure Nodes
Step 1:
In node1 locate the web.xml file (opt/local/zephyr/tomcat/webapps/flex/WEB-INF/web.xml)
Step 2:
Locate 'AtmosphereServlet' in the file and add the below mentioned lines as an additional 'init-param' tag:
<init-param> <param-name>org.atmosphere.cpr.AtmosphereInterceptor</param-name> <param-value>org.atmosphere.interceptor.NginxInterceptor</param-value> </init-param>
Sample web.xml file:
Step 3:
In web.xml (default path: opt/local/zephyr/tomcat/conf/web.xml) add the <distributable/> tag at the end of the file, before </web-app>
Sample web.xml file:
Step 4:
Follow steps 1-3 for node2
Step 5:
In the conf folder for NGINX, find the file named nginx.conf. Under upstream add both the IP addresses:
upstream tomcat{ ip_hash; server 192.168.11.192:81; server 192.168.11.98:81; }
Step 6:
Restart Nginx and launch Zephyr with the IP address of Nginx (e.g.: 192.168.11.153/flex). You will be redirected to any one of the configured Nodes