Tuesday, 16 July 2019

Nginx configuration for load balancer

Create a conf file under location /etc/nginx/conf.d with any name and extension .conf :


server {
    listen       80;
    server_name  <server>;

    location /ctx01 {
        proxy_pass     http://host:port/ctx01/;
    }

    location /ctx02 {
        proxy_pass     http://host:port/ctx02/;
    }

    location / {
                root   /usr/share/nginx/html;
                index  index.html;
        }
}


This will redirect the request with /ctx01 to  http://host:port/ctx01.
Request with /ctx02 to  http://host:port/ctx02.

For e.g.  http://<server>:80/ctx01 will redirect to http://host:port/ctx01


If you want to have a home page, configure index.html under /usr/share/nginx/html.

No comments:

Post a Comment

Thank You for your valuable comment

Difference between class level and object locking and static object lock

1) Class level locking will lock entire class, so no other thread can access any of other synchronized blocks. 2) Object locking will lo...