Trouble getting NGINX to serve static content for specific directory from CDN via proxy

cn flag

I would like to serve static files from my remote CDN URL:

These need to be reached via proxy from my website URLs (without redirecting) at:

Having trouble getting this to work via NGINX's try_files.

Here's what my current NGINX config for this looks like:

location /files/ {
    try_files $uri @cdn;

location @cdn {
  set $cdn_url   '';
  set $url_full         'project/$1';

  proxy_set_header       Host $cdn_url;
  proxy_set_header       Authorization '';
  proxy_pass             https://$cdn_url$url_full;

I've read through and tried some of the solutions here, but I can't seem to get it working:

What am I doing wrong?


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.