Set up Nginx

This depends a lot on your general Nginx setup, but there should be nothing special about this config file apart from redirecting API requests to gunicorn and static files to the /static/ directory.

sudoedit /etc/nginx/sites-available/glitchtip
server {
        listen [::]:443 ssl http2;
        listen 443 ssl http2;
        server_name bugs.example.com;
        access_log /var/log/nginx/bugs.example.com.access.log;
        error_log /var/log/nginx/bugs.example.com.error.log;

        ssl_certificate /etc/letsencrypt/live/bugs.example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/bugs.example.com/privkey.pem;

        add_header Strict-Transport-Security max-age=15768000;

        location ~ /\.git {
                deny all;
        }

        location / {
                alias /srv/server/glitchtip/code/static/;
                try_files $uri $uri/index.html /index.html;
                expires 1h;
                add_header Pragma public;
                add_header Cache-Control "public";
        }
        location /media/ {
                alias /srv/server/glitchtip/code/media/;
        }

        location ~ ^/(api|admin|_health|rest-auth)/ {
                proxy_pass         http://unix:/srv/server/glitchtip/runtime/socket;
                proxy_redirect     off;
                proxy_set_header   Host                 $host;
                proxy_set_header   X-Real-IP            $remote_addr;
                proxy_set_header   X-Forwarded-For      $proxy_add_x_forwarded_for;
                proxy_set_header   X-Forwarded-Proto    $scheme;
        }
}
cd /etc/nginx/sites-enabled
sudo ln -s ../sites-available/glitchtip
sudo nginx -t && sudo service nginx reload

Now you should be able to use GlitchTip without issues in your browser (create a user and afterwards log in). But to complete the setup we also need to set up celery.


Revision #4
Created Fri, Jan 29, 2021 7:35 PM by Lukas
Updated Fri, Jan 29, 2021 7:40 PM by Lukas