Skip to content

Commit

Permalink
feat(nginx): enable gzip compression and cache control for static files
Browse files Browse the repository at this point in the history
  • Loading branch information
paularmstrong authored and blakeblackshear committed Jan 31, 2021
1 parent e651623 commit cc79299
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ http {

keepalive_timeout 65;

gzip on;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/x-javascript application/javascript text/javascript image/svg+xml image/x-icon image/bmp image/png image/gif image/jpeg image/jpg;
gzip_proxied no-cache no-store private expired auth;
gzip_vary on;

upstream frigate_api {
server localhost:5001;
keepalive 1024;
Expand Down Expand Up @@ -98,20 +104,31 @@ http {

location /api/ {
add_header 'Access-Control-Allow-Origin' '*';
add_header Cache-Control "no-store";
proxy_pass http://frigate_api/;
proxy_pass_request_headers on;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}


location / {
add_header Cache-Control "no-cache";

location ~* \.(?:js|css|svg|ico|png)$ {
access_log off;
expires 1y;
add_header Cache-Control "public";
}

sub_filter 'href="/' 'href="$http_x_ingress_path/';
sub_filter 'url(/' 'url($http_x_ingress_path/';
sub_filter '"/js/' '"$http_x_ingress_path/js/';
sub_filter '<body>' '<body><script>window.baseUrl="$http_x_ingress_path";</script>';
sub_filter_types text/css application/javascript;
sub_filter_once off;

root /opt/frigate/web;
try_files $uri $uri/ /index.html;
}
Expand Down

0 comments on commit cc79299

Please sign in to comment.