This article is a mirror article of machine translation, please click here to jump to the original article.

View: 13270|Reply: 2

php nginx uses X-Accel-Redirect to control file download permissions

[Copy link]
Posted on 5/25/2018 9:20:49 AM | | |
demand
There is a page (php) with a button that needs to control the download permission, and only users who have paid can download it; The nginx used by our server was searched and decided to use X-Accel-Redirect;

realized
It's quite simple, two steps, but I didn't understand it at first, and I took a lot of detours;
1. Configure nginx

Here internal means that the url starting with /me/Public/courseFile/ can only be accessed internally;
alias is followed by the file storage folder (absolute path);

2. Use of PHP code
I'll just add the code here









Previous:SSO single sign-on is a P3P protocol for synchronous login/exit
Next:Fix ucenter error in https case
 Landlord| Posted on 5/25/2018 9:43:00 AM |
Different web servers implement different HTTP headers
SENDFILE headerWEB server used
X-SendfileApache, Lighttpd v1.5, Cherokee
X-LIGHTTPD-send-fileLighttpd v1.4
X-Accel-RedirectNginx, Cherokee


IIS implementation:https://github.com/stakach/IIS-X-Sendfile-plugin
Posted on 5/25/2018 12:54:50 PM |
666
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com