Last active
August 29, 2015 14:14
-
-
Save Bigcheese/58d78e8c9f6791abaff8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wsgiref | |
from wsgiref.util import setup_testing_defaults | |
from wsgiref.simple_server import make_server | |
def simple_app(environ, start_response): | |
setup_testing_defaults(environ) | |
if 'HTTP_AUTHORIZATION' in environ: | |
print('Authed!') | |
status = '200 OK' | |
headers = [('Content-Length', '0')] | |
else: | |
status = '401 FORBIDDEN' | |
headers = [('WWW-Authenticate', 'Basic realm="nmrs_m7VKmomQ2YM3:"'), ('Content-Length', '0')] | |
start_response(status, headers) | |
return [b"sefsefsefsefef"] | |
httpd = make_server('', 8080, simple_app) | |
print("Serving on port 8080...") | |
httpd.serve_forever() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 1; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; | |
keepalive_timeout 65; | |
server { | |
listen localhost:80; | |
server_name localhost; | |
location / { | |
root html; | |
index index.html index.htm; | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root html; | |
} | |
location /priv { | |
auth_request /auth; | |
} | |
location = /auth { | |
proxy_pass http://localhost:8080; | |
proxy_pass_request_body off; | |
proxy_set_header Content-Length ""; | |
proxy_set_header X-Original-URI $request_uri; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment