I am DEFINITELY not a developer lmao.
Discussion
It's probably fine for your use-case, but it could result in a false positive if the text on a webpage contains "Welcome to Nginx" for any reason, like this one now does.
You could take a hash of known server welcome pages and then compare the hash of the current page. But don't listen to me, simpler is always better until you absolutely need to make it more complicated.