Rewrite subdirectory URL to subdomain in Nginx

I have a droplet with a LEMP stack running a WordPress site. I have also uploaded a non-wordpress PHP app into the same root folder.

The non-wordpress PHP app can be viewed at example.com/php-app, but I would like to change the URL to php-app.example.com.

How can I achieve this with Nginx?