Adding conf to nginx

What would be the right way to add some custom functionality to my nginx setup?

I usually like to add a fallback for images, so i can quickly run a dev environment, with actually downloading all the content.

I do something like

# inside content block
location ~* /app/uploads {
  location ~* \.(js|css|png|jpe?g|gif|ico|svg)$ {
    try_files $uri @redirect_upstream;
    log_not_found off;
  }
}

location @redirect_upstream {
   rewrite (/app/uploads/)(.*)$ https://domain.com/wp-content/uploads/$1;
}

I want to add it to the recipes somewhere… perhaps in its own .conf file?
:pray:

1 Like