How to disable direct media file access in nginx or ubuntu for non loggedin users?

How to disable direct media file access in nginx or ubuntu for non loggedin users?

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)