Security setup for server

Is it possible to lock down the default port 4000 to only listen on the loop back interface after the NGINIX reverse proxy is setup.

Alternate idea is to allow it to only respond to a specific ip if a separate NGINIX box is setup as a proxy and is the only device that can talk to the server?

I’m setup on an Ubuntu server at the moment.

Would the simplest method be to just enable UFW and setup a rule to allow inbound connections on port 80 and 443. Also add in 22 for SSH from a restricted ip set if wanted.