Jonas Havelka
3 years ago
16 changed files with 192 additions and 109 deletions
@ -1,20 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
|
|
||||
from django.core.management.base import BaseCommand |
|
||||
from django.contrib.sessions.models import Session |
|
||||
from django.contrib.auth.models import User |
|
||||
|
|
||||
class Command(BaseCommand): |
|
||||
u"""Vypiš username přihlášeného orga s daným session_key. |
|
||||
|
|
||||
Příkaz pro manage.py, který ze vstupu přečte session_key (tak, jak je |
|
||||
uložen v cookie sessionid) a pokud session existuje a příslušný přihlášený |
|
||||
uživatel má právo přihlásit se do admina, vypíše jeho username. |
|
||||
""" |
|
||||
def handle(self, *args, **options): |
|
||||
session_key = raw_input() |
|
||||
s = Session.objects.get(pk=session_key).get_decoded() |
|
||||
user_id = s['_auth_user_id'] |
|
||||
user = User.objects.get(pk=user_id) |
|
||||
if user.is_staff: |
|
||||
print(user.username) |
|
@ -0,0 +1,3 @@ |
|||||
|
Tato složka obsahuje různé konfiguráky potřebné k rozběhnutí webu na serveru. |
||||
|
|
||||
|
TODO: Napsat sem i přehled toho, jak to funguje. |
@ -0,0 +1,50 @@ |
|||||
|
server { |
||||
|
listen 195.113.20.177:80; |
||||
|
listen [2001:718:1e03:801::b1]:80; |
||||
|
server_name mam-test.ks.matfyz.cz; |
||||
|
return 301 https://$server_name$request_uri; |
||||
|
|
||||
|
} |
||||
|
server { |
||||
|
# SSL configuration |
||||
|
listen 195.113.20.177:443 ssl; |
||||
|
listen [2001:718:1e03:801::b1]:443 ssl; |
||||
|
|
||||
|
# SSL keys |
||||
|
ssl on; |
||||
|
ssl_certificate /etc/letsencrypt/live/mam-test.ks.matfyz.cz/fullchain.pem; # managed by Certbot |
||||
|
ssl_certificate_key /etc/letsencrypt/live/mam-test.ks.matfyz.cz/privkey.pem; # managed by Certbot |
||||
|
ssl_dhparam /etc/ssl/dhparams.pem; |
||||
|
ssl_session_cache shared:SSL:10m; |
||||
|
ssl_session_timeout 5m; |
||||
|
|
||||
|
server_name mam-test.ks.matfyz.cz; |
||||
|
|
||||
|
client_max_body_size 50M; |
||||
|
|
||||
|
auth_basic "MaMweb test - access restricted"; |
||||
|
auth_basic_user_file /akce/mam/www/mamweb-test/.htpasswd; |
||||
|
|
||||
|
location /static/ { |
||||
|
root /akce/mam/www/mamweb-test/; |
||||
|
} |
||||
|
|
||||
|
location /media/ { |
||||
|
root /akce/mam/www/mamweb-test/; |
||||
|
} |
||||
|
|
||||
|
location /aesop-export/ { |
||||
|
auth_basic "AESOP API"; |
||||
|
auth_basic_user_file /akce/mam/www/mamweb-test/.htpasswd-aesop; |
||||
|
try_files $uri @mamweb_test; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
location / { try_files $uri @mamweb_test; } |
||||
|
|
||||
|
location @mamweb_test { |
||||
|
include uwsgi_params; |
||||
|
uwsgi_pass unix:/tmp/uwsgi-mamweb_test.sock; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,65 @@ |
|||||
|
|
||||
|
server { |
||||
|
listen 195.113.20.177:80; |
||||
|
listen [2001:718:1e03:801::b1]:80; |
||||
|
server_name mam.mff.cuni.cz; |
||||
|
return 301 https://$server_name$request_uri; |
||||
|
|
||||
|
} |
||||
|
server { |
||||
|
# SSL configuration |
||||
|
# |
||||
|
listen 195.113.20.177:443 ssl; |
||||
|
listen [2001:718:1e03:801::b1]:443 ssl; |
||||
|
|
||||
|
# SSL keys |
||||
|
ssl on; |
||||
|
ssl_certificate /etc/ssl/domains/mam.mff.cuni.cz/bundle.pem; |
||||
|
ssl_certificate_key /etc/ssl/domains/mam.mff.cuni.cz/privkey.pem; |
||||
|
ssl_dhparam /etc/ssl/dhparams.pem; |
||||
|
ssl_session_cache shared:SSL:10m; |
||||
|
ssl_session_timeout 5m; |
||||
|
|
||||
|
|
||||
|
server_name mam.mff.cuni.cz; |
||||
|
# server_name mamweb.bezva.org; |
||||
|
|
||||
|
client_max_body_size 50M; |
||||
|
|
||||
|
location /aesop-export/ { |
||||
|
auth_basic "AESOP API"; |
||||
|
auth_basic_user_file /akce/mam/www/mamweb-prod/.htpasswd-aesop; |
||||
|
try_files $uri @mamweb_prod; |
||||
|
} |
||||
|
|
||||
|
location /static/ { |
||||
|
root /akce/mam/www/mamweb-prod/; |
||||
|
} |
||||
|
|
||||
|
location /media/ { |
||||
|
root /akce/mam/www/mamweb-prod/; |
||||
|
} |
||||
|
|
||||
|
location /wiki/ { |
||||
|
proxy_pass http://127.0.0.1:5001/; |
||||
|
proxy_set_header X-Real_IP $remote_addr; |
||||
|
proxy_redirect / /wiki/; |
||||
|
#rewrite '/' '/wiki'; |
||||
|
sub_filter_once off; |
||||
|
sub_filter 'href="/' 'href="/wiki/'; |
||||
|
sub_filter 'src="/' 'src="/wiki/'; |
||||
|
sub_filter 'action="/' 'action="/wiki/'; |
||||
|
# Overkill: |
||||
|
#sub_filter '="/' '="/wiki/'; |
||||
|
#sub_filter ':5001/' '/wiki/'; |
||||
|
#sub_filter 'Location: /' 'Location: /wiki/'; |
||||
|
#sub_filter '_login' '_test'; |
||||
|
} |
||||
|
|
||||
|
location / { try_files $uri @mamweb_prod; } |
||||
|
|
||||
|
location @mamweb_prod { |
||||
|
include uwsgi_params; |
||||
|
uwsgi_pass unix:/tmp/uwsgi-mamweb_prod.sock; |
||||
|
} |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
[Unit] |
||||
|
Description=uWSGI instance to serve mam.mff.cuni.cz |
||||
|
After=network.target |
||||
|
|
||||
|
[Service] |
||||
|
WorkingDirectory=/akce/mam/www/mamweb-prod |
||||
|
ExecStart=/usr/bin/uwsgi --ini mamweb_prod.ini |
||||
|
|
||||
|
[Install] |
||||
|
WantedBy=default.target |
@ -0,0 +1,10 @@ |
|||||
|
[Unit] |
||||
|
Description=uWSGI instance to serve mam-test.kam.mff.cuni.cz |
||||
|
After=network.target |
||||
|
|
||||
|
[Service] |
||||
|
WorkingDirectory=/akce/mam/www/mamweb-test |
||||
|
ExecStart=/usr/bin/uwsgi --ini mamweb_test.ini |
||||
|
|
||||
|
[Install] |
||||
|
WantedBy=default.target |
Loading…
Reference in new issue