mirror of
				https://github.com/blakeblackshear/frigate.git
				synced 2025-10-27 10:52:11 +01:00 
			
		
		
		
	feat(nginx): enable gzip compression and cache control for static files
This commit is contained in:
		
							parent
							
								
									e6516235fa
								
							
						
					
					
						commit
						cc7929932b
					
				@ -23,6 +23,12 @@ http {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    keepalive_timeout  65;
 | 
					    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 {
 | 
					    upstream frigate_api {
 | 
				
			||||||
      server localhost:5001;
 | 
					      server localhost:5001;
 | 
				
			||||||
      keepalive 1024;
 | 
					      keepalive 1024;
 | 
				
			||||||
@ -98,6 +104,7 @@ http {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        location /api/ {
 | 
					        location /api/ {
 | 
				
			||||||
            add_header 'Access-Control-Allow-Origin' '*';
 | 
					            add_header 'Access-Control-Allow-Origin' '*';
 | 
				
			||||||
 | 
					            add_header Cache-Control "no-store";
 | 
				
			||||||
            proxy_pass http://frigate_api/;
 | 
					            proxy_pass http://frigate_api/;
 | 
				
			||||||
            proxy_pass_request_headers on;
 | 
					            proxy_pass_request_headers on;
 | 
				
			||||||
            proxy_set_header Host $host;
 | 
					            proxy_set_header Host $host;
 | 
				
			||||||
@ -105,13 +112,23 @@ http {
 | 
				
			|||||||
            proxy_set_header X-Forwarded-Proto $scheme;
 | 
					            proxy_set_header X-Forwarded-Proto $scheme;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        location / {
 | 
					        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 'href="/' 'href="$http_x_ingress_path/';
 | 
				
			||||||
            sub_filter 'url(/' 'url($http_x_ingress_path/';
 | 
					            sub_filter 'url(/' 'url($http_x_ingress_path/';
 | 
				
			||||||
            sub_filter '"/js/' '"$http_x_ingress_path/js/';
 | 
					            sub_filter '"/js/' '"$http_x_ingress_path/js/';
 | 
				
			||||||
            sub_filter '<body>' '<body><script>window.baseUrl="$http_x_ingress_path";</script>';
 | 
					            sub_filter '<body>' '<body><script>window.baseUrl="$http_x_ingress_path";</script>';
 | 
				
			||||||
            sub_filter_types text/css application/javascript;
 | 
					            sub_filter_types text/css application/javascript;
 | 
				
			||||||
            sub_filter_once off;
 | 
					            sub_filter_once off;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            root /opt/frigate/web;
 | 
					            root /opt/frigate/web;
 | 
				
			||||||
            try_files $uri $uri/ /index.html;
 | 
					            try_files $uri $uri/ /index.html;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user