ngx_http_auth_request_module
location /private/ {
auth_request /auth;
...
}
location = /auth {
proxy_pass ...
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
import SimpleHTTPServer | |
import SocketServer | |
PORT = 8000 | |
class Server(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def do_GET(self): | |
headers = self.headers.dict | |
# curl http://127.0.0.1:8000 -u username:password | |
if self.headers.dict.get('authorization') != 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=': | |
self.send_response(401) | |
else: | |
self.send_response(200) | |
def serve_forever(port): | |
httpd = SocketServer.TCPServer(('', port), Server) | |
httpd.serve_forever() | |
if __name__ == "__main__": | |
serve_forever(8000) |