如何让上传仅对登录用户可用

for example:

I posted in this post

https://example.com/aaa/111.txt

Guest users can see this post, But if download 111.txt, the guest user must log in.

/aaa/111.txt provided by nginx.

I have try Discourse SSO in Nginx , Seems to have failed.