NGINX-缓存静态(CSS/JS)文件后出现404错误

NGINX-缓存静态(CSS/JS)文件后出现404错误,nginx,caching,http-status-code-404,cache-control,Nginx,Caching,Http Status Code 404,Cache Control,我正在尝试设置nginx来缓存静态文件,如jpg、jpeg、css和js 下面是我的nginx.conf(不是nginx.conf.default)的样子 events {} http { server { listen 3000; # listen 443 ssl; server_name localhost; # Set the SSL header only for HTTPS requests. if ($scheme

我正在尝试设置nginx来缓存静态文件,如jpg、jpeg、css和js

下面是我的nginx.conf(不是nginx.conf.default)的样子

events {}
http {

 server {
    listen       3000;
    # listen       443 ssl;
    server_name  localhost;
    # Set the SSL header only for HTTPS requests.
    if ($scheme = "https") {
        set $ssl_header SSL;
    }
    error_page 401 = @error401;
    client_max_body_size 1000M;

    # Expire rules for static content
    location / {
        # HTTPS header.
        proxy_set_header        X-Proto $ssl_header;
        proxy_set_header        Host $host;
        proxy_set_header        Client-IP $remote_addr;

        # Redirection host.
        proxy_pass              http://localhost:300x;

     }

      location ~* .(jpg|jpeg|css|js)$ {
         expires 1d;
         access_log off;
         add_header Cache-Control "public";
      }
然后,我尝试将以下内容添加到缓存:

        location ~* .(jpg|jpeg|css|js)$ {
        expires 1d;
        access_log off;
        add_header Cache-Control "public";
        }
我所有的CSS&JS文件都有404个错误。我的JPG和JPEG文件被缓存。我已经厌倦了在这里添加根目录和in location\{}块。这似乎没有什么区别

我已经尝试了许多不同的配置-我只是想知道如何缓存我的css和js文件

供参考:这是我的nginx.conf.default文件中的位置块:

        location / {
        root   html;
        index  index.html index.htm;
        }
我已尝试在服务器块中添加根,但没有成功