~
This commit is contained in:
commit
9aa2193149
44
README.md
Normal file
44
README.md
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
# nginx-useragent-auth
|
||||||
|
|
||||||
|
This document provides you with an idea and a solution for restricting web access to a certain resource or location by specifying a custom useragent.
|
||||||
|
|
||||||
|
If you want to access a file on your webserver, but you also don't want it to be publicly accessible, then you maybe found out about http basic auth, but then you noticed that it's not so convenient to use with mpv and this is exactly where this solution comes and saves your day and future.
|
||||||
|
|
||||||
|
`mpv` has a config option that lets you specify a custom useragent: https://github.com/mpv-player/mpv/blob/master/etc/mpv.conf#L99
|
||||||
|
|
||||||
|
Specify a your personal auth token in your mpv.conf then;
|
||||||
|
|
||||||
|
|
||||||
|
`sudo vim /etc/nginx/nginx.conf`
|
||||||
|
|
||||||
|
```json
|
||||||
|
map $http_useragent $auth {
|
||||||
|
default 0;
|
||||||
|
"your custom user agent (for example a 128 char string or more or less)" 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
`sudo vim your-vhost-config.conf`
|
||||||
|
|
||||||
|
```json
|
||||||
|
location /private-location/ {
|
||||||
|
if ($auth = 0) {
|
||||||
|
## UNAUTHORIZED
|
||||||
|
# for example return to a location or 403
|
||||||
|
#return 302 /dl/;
|
||||||
|
return 403;
|
||||||
|
}
|
||||||
|
|
||||||
|
## AUTHORIZED
|
||||||
|
# for example publish your file server or return
|
||||||
|
#proxy_pass http://backend/;
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If set up properly this will let you just paste the full url of your file and use it with mpv
|
||||||
|
|
||||||
|
`mpv <url>`
|
||||||
|
|
||||||
|
no more url modifications for http basic auth
|
Loading…
Reference in New Issue
Block a user