There are some cases we only need Nginx cache enabled for anonymous users. I can show two ways on how to disable Nginx cache when user is authenticated and enable it for anonymous users in Drupal.
Method 1: Using Cookie
This method invloves Drupal custom module to set an identifier in Cookie that a user is authenticated.
The custom module uses hook_user_login() to set "nocache=1" in Cookie if user is logged in and hook_user_logout() to set "nocache=0" if user is logged out. The codes are as follows (you can download the custom module below this article):