blck

ephemeral pastebin/url shortener
git clone https://git.parazyd.org/blck
Log | Files | Refs | README | LICENSE

commit af48387155ff2508b48b13717f1ecdc8eddba379
parent 5067470361bfa6f1bfdd652f0223929e5f2f075f
Author: parazyd <parazyd@dyne.org>
Date:   Tue, 21 Mar 2017 12:39:07 +0100

ssl support

Diffstat:
MREADME.md | 39+++++++++++++++++++++++++++++++++++++++
Mblck.py | 6++++--
2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md @@ -11,6 +11,44 @@ get `python-flask` and execute `blck.py`. by default it starts on `localhost:5000`, but you can configure it at the bottom of the script. +nginx +----- + +``` +server { + listen 80; + listen [::]:80; + server_name blck.cf; + + location /.well-known/acme-challenge/ { + alias /tmp/blckssl/; + try_files $uri =404; + } + + return 301 https://$server_name$request_uri; +} + +server { + listen 443 ssl; + listen [::]:443 ssl; + server_name blck.cf; + + ssl_certificate /etc/ssl/blck.cf.pem; + ssl_certificate_key /etc/ssl/blck.cf.key; + + error_log /var/log/nginx/blck.cf_error.log warn; + access_log /var/log/nginx/blck.cf_access.log combined; + + location / { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto https; + proxy_pass http://127.0.0.1:5000; + } +} +``` + + usage ----- @@ -20,6 +58,7 @@ either use the website, or curl: curl -F 'url=https://github.com/parazyd/blck.cf' http://blck.cf ``` + how does it work? ----------------- diff --git a/blck.py b/blck.py @@ -53,6 +53,9 @@ def s(url): except: return "could not save url\n" + if flask.request.headers.get('X-Forwarded-Proto') == 'https': + return flask.request.url_root.replace('http://', 'https://') + urlshort + '\n' + return flask.request.url_root + urlshort + '\n' @@ -60,5 +63,4 @@ def genid(size=4, chars=string.ascii_uppercase + string.ascii_lowercase): return ''.join(random.choice(chars) for i in range(size)) -if __name__ == "__main__": - app.run(host="127.0.0.1", port=5000) +app.run(host="127.0.0.1", port=5000)