Nginx is a web server also used as a reverse proxy, load balancer and cache. In Joomla infrastructure, it can serve static files and forward dynamic requests to PHP or another web server.
Request processing
A server block selects website settings, while location rules control matching paths. Nginx does not execute PHP itself. With PHP-FPM, it sends requests through FastCGI over a socket or network connection.
Nginx may sit in front of Apache. In that setup, both servers' rules and logs affect the final response.
Joomla considerations
The .htaccess file belongs to Apache and is not read by Nginx. Joomla SEF routing rules must be configured in Nginx or the appropriate upstream server. Copying .htaccess alone does not configure routing.
After changes, validate configuration syntax and test actual Joomla journeys: articles, login, forms, downloads and language versions. A 502 response may involve an upstream connection problem, but logs are needed to establish the cause.
Conclusion
Nginx handles web requests and passes work to other services. Its configuration must fit the complete website request chain.