Skip to content

Commit

Permalink
fix: nginx config to serve fonts locally (#7551)
Browse files Browse the repository at this point in the history
Co-authored-by: off <off@openfoodfacts.org>
  • Loading branch information
stephanegigandet and off committed Oct 19, 2022
1 parent 2825bd2 commit 0e4b5a4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
8 changes: 5 additions & 3 deletions conf/nginx/sites-available/obf
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ server {
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;

location ~* \.(json|csv|eot|ttf|woff|woff2)$ {
add_header Access-Control-Allow-Origin *;
location ~* \.(eot|ttf|woff|woff2)$ {
add_header Access-Control-Allow-Origin *;
}

location ~ ^/images/products/ {
Expand All @@ -116,7 +116,9 @@ server {
try_files $uri $uri/ =404;
}

location ~ ^/(.well-known|images|css|js|rss|files|resources|foundation|bower_components)/ {
location ~ ^/(.well-known|images|fonts|css|js|rss|files|resources|foundation|bower_components)/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
Expand Down
18 changes: 10 additions & 8 deletions conf/nginx/sites-available/off
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ server {
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,If-None-Match';
add_header Access-Control-Expose-Headers 'Content-Length,Content-Range';
# optimize gzip compressed content (like OCR .json stored next to .jpg files)
gzip_static always;
gunzip on;
# optimize gzip compressed content (like OCR .json stored next to .jpg files)
gzip_static always;
gunzip on;
}

if ($http_referer ~* (jobothoniel.com) ) { return 403; } # blocked since 2021-07-13
Expand All @@ -187,7 +187,9 @@ server {

# Static files are served directly by NGINX

location ~ ^/(.well-known|images|css|js|rss|files|resources|foundation|bower_components)/ {
location ~ ^/(.well-known|images|fonts|css|js|rss|files|resources|foundation|bower_components)/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
gzip_static always;
Expand Down Expand Up @@ -263,10 +265,10 @@ server {
}

location = /ecoscore {
if ( $host ~ "^fr\..*" ) {
return 301 https://$host/eco-score-l-impact-environnemental-des-produits-alimentaires;
}
return 301 https://$host/eco-score-the-environmental-impact-of-food-products;
if ( $host ~ "^fr\..*" ) {
return 301 https://$host/eco-score-l-impact-environnemental-des-produits-alimentaires;
}
return 301 https://$host/eco-score-the-environmental-impact-of-food-products;
}

# 2022-06-13 Redirect press pages to blog post about the new Flutter app
Expand Down
4 changes: 3 additions & 1 deletion conf/nginx/sites-available/opf
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ server {
}


location ~ ^/(.well-known|images|css|js|rss|files|resources|foundation|bower_components)/ {
location ~ ^/(.well-known|images|fonts|css|js|rss|files|resources|foundation|bower_components)/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
Expand Down
4 changes: 3 additions & 1 deletion conf/nginx/sites-available/opff
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ server {
}


location ~ ^/(.well-known|images|css|js|rss|files|resources|foundation|bower_components)/ {
location ~ ^/(.well-known|images|fonts|css|js|rss|files|resources|foundation|bower_components)/ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
Expand Down

0 comments on commit 0e4b5a4

Please sign in to comment.