Add improved nginx configuration #5

Open
opened 2023-10-20 20:47:00 +00:00 by nicksellen · 0 comments
Member

Two modifications here:

1. attachments

To support viewing attachments in a way that a) checks user permissions, and b) still serves the content effeciently via nginx, these nginx blocks were added more recently than when the recipe was made (see 26e36067c4/roles/karrot-backend/templates/nginx.j2 (L103-L120)):

    # never serve up the tmp content
    location /media/tmp/ {
        deny all;
        return 404;
    }

    # these are served via django
    location ~ /media/conversation_message_attachment_(files|previews|thumbnails)/ {
        deny all;
        return 404;
    }

    # support for X-Accel-Redirect
    location /uploads/ {
        internal;
        alias /var/www/{{ site }}/www/{{ uploads_directory }}/;
	    etag on;
    }

To actually use the X-Accel-Redirect support it would also need adding in the karrot app environment as:

FILE_UPLOAD_USE_ACCEL_REDIRECT=true

2. serve django static content

Current:

location ~ ^\/(api(\-auth)?|docs|silk)\/ {

Change to:

location ~ ^\/(api(\-auth)?|docs|silk|static)\/ {

This means the swagger API interface should work again (should be viewable at /docs/)

Two modifications here: # 1. attachments To support viewing attachments in a way that a) checks user permissions, and b) still serves the content effeciently via nginx, these nginx blocks were added more recently than when the recipe was made (see https://github.com/karrot-dev/yuca/blob/26e36067c42290481a654bf42dc79646c3e249cc/roles/karrot-backend/templates/nginx.j2#L103-L120): ``` # never serve up the tmp content location /media/tmp/ { deny all; return 404; } # these are served via django location ~ /media/conversation_message_attachment_(files|previews|thumbnails)/ { deny all; return 404; } # support for X-Accel-Redirect location /uploads/ { internal; alias /var/www/{{ site }}/www/{{ uploads_directory }}/; etag on; } ``` To actually use the `X-Accel-Redirect` support it would also need adding in the karrot app environment as: ``` FILE_UPLOAD_USE_ACCEL_REDIRECT=true ``` # 2. serve django static content Current: ``` location ~ ^\/(api(\-auth)?|docs|silk)\/ { ``` Change to: ``` location ~ ^\/(api(\-auth)?|docs|silk|static)\/ { ``` This means the swagger API interface should work again (should be viewable at `/docs/`)
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: coop-cloud/karrot#5
No description provided.