diff --git a/MUOR/MUOR/NGINXConfigurator.py b/MUOR/MUOR/NGINXConfigurator.py index 1c0529d15..400bd9052 100644 --- a/MUOR/MUOR/NGINXConfigurator.py +++ b/MUOR/MUOR/NGINXConfigurator.py @@ -2,9 +2,9 @@ import subprocess class NGINXConfigurator: - _config_path = "/etc/nginx/conf.d/muor.conf" - _location_preamble_path = "configs/muor_before_location_block.conf" - _location_epilouge_path = "configs/muor_after_location_block.conf" + _config_path = "/etc/nginx/nginx.conf" + _location_preamble_path = "MUOR/configs/muor_before_location_block.conf" + _location_epilouge_path = "MUOR/configs/muor_after_location_block.conf" @classmethod def refresh_config(cls, sessions): @@ -14,7 +14,7 @@ class NGINXConfigurator: config = cls._get_config(sessions) with open(cls._config_path, 'w') as F: F.write(config) - completed_process = subprocess.run(["nginx", "-s", "reload"]) + completed_process = subprocess.run(["sudo" "nginx", "-s", "reload"]) return completed_process.returncode @classmethod diff --git a/MUOR/MUOR/configs/muor_after_location_block.conf b/MUOR/MUOR/configs/muor_after_location_block.conf index cfb4fcfff..0969335d8 100644 --- a/MUOR/MUOR/configs/muor_after_location_block.conf +++ b/MUOR/MUOR/configs/muor_after_location_block.conf @@ -1,10 +1,6 @@ if ($cookie_sessionid = ""){ - uwsgi_read_timeout 600; - uwsgi_send_timeout 600; - uwsgi_connect_timeout 60; - uwsgi_ignore_client_abort on; - uwsgi_pass django; + proxy_pass django; # TODO prolly change that to uwsgi_pass } } diff --git a/MUOR/MUOR/configs/muor_before_location_block.conf b/MUOR/MUOR/configs/muor_before_location_block.conf index 93ea33080..1284230b5 100644 --- a/MUOR/MUOR/configs/muor_before_location_block.conf +++ b/MUOR/MUOR/configs/muor_before_location_block.conf @@ -1,8 +1,14 @@ + + map $http_upgrade $connection_upgrade { default upgrade; '' close; } +upstream django { + server localhost:8080 +} + server { listen 80 reuseport; server_name randomsec.projektstudencki.pl; @@ -30,4 +36,4 @@ server { # Finally, send all non-media requests to the Django server. - location / { \ No newline at end of file + location / { diff --git a/MUOR/MUOR/signals.py b/MUOR/MUOR/signals.py index 1695078ea..ba80d9dfb 100644 --- a/MUOR/MUOR/signals.py +++ b/MUOR/MUOR/signals.py @@ -8,7 +8,7 @@ from django.conf import settings def get_sessions_data(): - return tuple((session.profile.volume, session.port, session.sessionid) + return tuple((session.user.volume, session.port, session.sessionid) for session in Session.objects.all()) @@ -26,7 +26,8 @@ def profile_saved(sender, instance, **kwargs): @receiver(user_logged_in) def profile_start_up(sender, user, request, **kwargs): try: - user.session = request.session.session_key + user.session + user.session.sessionid = request.session.session_key user.session.save() except Profile.session.RelatedObjectDoesNotExist: # Create session