server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name _;

        location / {
                return 301 https://$host$request_uri;
        }
}

server {
        listen 443 ssl;
        listen [::]:443 ssl;

	ssl_protocols TLSv1.2 TLSv1.3;
	ssl_certificate /etc/nginx/ssl/ping.crt;
	ssl_certificate_key /etc/nginx/ssl/ping.key;

        server_name archive;

        location /ws/status/ {
                proxy_pass http://user:8003;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection $connection_upgrade;
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;

                #disable buffering for websockets
                proxy_buffering off;
        }

        location /chat/ {
                proxy_pass http://chat:8004;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection $connection_upgrade;
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
        }

        location /users_list/ {
                proxy_pass http://chat:8004;
                proxy_http_version 1.1;
                proxy_set_header Host $host;
        }

        location /auth/ {
                proxy_pass http://user:8003;
                proxy_http_version 1.1;
                proxy_set_header Host $host;
        }

        location /static/ {
                alias /usr/share/nginx/static/;
        }

        location /media/ {
                alias /home/archive/user_auth_system/media/;
        }

        location / {
                alias /usr/share/nginx/html/;
                try_files $uri /index.html;
        }
}
