Skip to content

Commit

Permalink
Merge pull request #3338 from Minnozz/fix-nginx-location
Browse files Browse the repository at this point in the history
Make nginx config safer
  • Loading branch information
Minnozz committed Apr 3, 2024
2 parents d1d91f0 + 75bc4f8 commit 5082806
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
19 changes: 9 additions & 10 deletions nginx/development
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,22 @@ server {
# directly serve static files from the
# bookwyrm filesystem using sendfile.
# make the logs quieter by not reporting these requests
location ~ ^/static/ {
location /static/ {
root /app;
try_files $uri =404;
add_header X-Cache-Status STATIC;
access_log off;
}

# same with image files not in static folder
location ~ \.(bmp|ico|jpg|jpeg|png|svg|tif|tiff|webp)$ {
root /app;
try_files $uri =404;
add_header X-Cache-Status STATIC;
access_log off;
}

# block access to any non-image files from images
location ~ ^/images/ {
location /images/ {
location ~ \.(bmp|ico|jpg|jpeg|png|svg|tif|tiff|webp)$ {
root /app;
try_files $uri =404;
add_header X-Cache-Status STATIC;
access_log off;
}
# block access to any non-image files from images
return 403;
}

Expand Down
21 changes: 10 additions & 11 deletions nginx/production
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,22 @@ server {
# # directly serve static files from the
# # bookwyrm filesystem using sendfile.
# # make the logs quieter by not reporting these requests
# location ~ ^/static/ {
# location /static/ {
# root /app;
# try_files $uri =404;
# add_header X-Cache-Status STATIC;
# access_log off;
# }

#
# # same with image files not in static folder
# location ~ \.(bmp|ico|jpg|jpeg|png|svg|tif|tiff|webp)$ {
# root /app;
# try_files $uri =404;
# add_header X-Cache-Status STATIC;
# access_log off;
# }

# # block access to any non-image files from images
# location ~ ^/images/ {
# location /images/ {
# location ~ \.(bmp|ico|jpg|jpeg|png|svg|tif|tiff|webp)$ {
# root /app;
# try_files $uri =404;
# add_header X-Cache-Status STATIC;
# access_log off;
# }
# # block access to any non-image files from images
# return 403;
# }
#
Expand Down

0 comments on commit 5082806

Please sign in to comment.