Sure, but this of course only works if nginx is running on the same server as Mattermost, otherwise a localhost connection is not possible.
In order to make sure Mattermost only listens on the local interface, you will need to change the Listen Address
in System Console → Environment → Web Server to 127.0.0.1:8065
(The default value :8065
means that it will listen on all interfaces on the server, therefore nginx could be bypassed).
You need to restart Mattermost for the change to take effect and you can verify that this is working by comparing the outputs of lsof -i :8065
on your Mattermost server before and after the change (you should see *:8065
before and 127.0.0.1:8065
afterwards).