I am a newbie in the world of Nginx. While learning it, I am trying to accomplish this: I want to return a string whenever someone hits this URL: /greet/user and the string will be 'Hello user.' So, if someone hits localhost/greet/john, the page will show this string: 'Hello john'; if the URL is localhost/greet/merry, the string will be 'Hello merry.'
I tried doing that with the following code fragment. To note, I did use a regular expression to catch any argument that came second.
location ~/greet/(user+) {
set $user user;
return 200 'Hello ${user}';
}
What am I missing here? And how should it be done? My OS is Ubuntu 22.04. This is my first post on server fault, and I am new to the world of web servers. So, if I miss out on anything while writing this post, I hope I will not receive any penalty.