Sunday 1 December 2019

NGINX: location: Match exact uri


Using = operator, we can match exact uris.

location = /welcome {
         return 200 "Hey, welcome to NGINX";
}
  
nginx.conf
events {
    
}

http {
    server {
        listen 9090;

        server_name localhost;

        location = /welcome {
            return 200 "Hey, welcome to NGINX";
        }
    }
}


Validate and reload the configuration.
$sudo nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
$
$sudo nginx -s reload

Open the url 'http://localhost:9090/welcome' in browser, you can see below screen.
Previous                                                    Next                                                    Home

No comments:

Post a Comment