I'd like to set up nuxt with NGINX as load balancer. Additionally, I'd like to add some caching to the images.
Now I get 404 for my images using this:
location ~ ^/img.+\.(?:ico|gif|jpe?g|webp|png|woff2?|eot|otf|ttf|svg|js|css)$ {
expires 365d;
add_header Pragma public;
add_header Cache-Control "public";
try_files $uri $uri/ @proxy;
}
location @proxy {
expires 365d;
add_header Content-Security-Policy "default-src 'self' 'unsafe-inline';";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Cache-Status $upstream_cache_status;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_ignore_headers Cache-Control;
proxy_http_version 1.1;
proxy_read_timeout 1m;
proxy_connect_timeout 1m;
proxy_pass http://1649681_app/$request_uri;
#proxy_cache nuxt-cache;
#proxy_cache_bypass $arg_nocache; # probably better to change this
#proxy_cache_valid 200 302 60m; # set this to your needs
#proxy_cache_valid 404 1m; # set this to your needs
#proxy_cache_lock on;
#proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
#proxy_cache_key $uri$is_args$args;
}
It seems like $request_uri
is wrong in the line proxy_pass http://1649681_app/$request_uri
- but how can I pass the requested path to the @proxy
-location?