last day (14 days later) » 

12:28 AM
0
Q: Nginx configuration not working

xorinzorI've just switched from Apache to nginx and it still takes some getting used to (and a lot of learning). I'm running a Pagekit website which has this configuration: https://gist.github.com/DarrylDias/be8955970f4b37fdd682 server { listen 80; listen [::]:80; # SSL configuration ...

 
The querystring won't be matched by location block. Is your nginx server behind of some kinds of CDNs? It may be caused by caches on those CDN servers. Try change the URL to example.com/app/js/something.min.js?v=1922 to bypass the cache.
 
I'm using cloudflare, but I've put myself in development mode and made sure to clear the cache. I know for a fact though that the url is like that because of pagekit itself
 
The cache is stored serverside by Cloudflare so only browser development mode won't work actually. Perhaps you can just change the version number from "1921" to any other string and see if it will work, after you moved the last location to the top.
 
I'm afraid that's not something I can change. I'm trying to find / write a regex that ignores the query string, but so far no luck
 
Actually you can. Just copy the URL and change the parameter, then browse the JS file directly to see if still a 403 returned.
 
12:28 AM
oh, yeah you're right. forgot about that. Unfortunately that too returns a 403
 
How about add a "break;" after the last add_header line? Not sure but it might be the problem. (You still need to adjust the list order).
 
Doesn't seem to help either :/ (It's already at the top)
 
Can you update the question to the new configuration you modified?
 
done
 
location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff)\$ {
access_log off;
expires 30d;
add_header Pragma public;
add_header Cache-Control "public, mustrevalidate, proxy-revalidate";
}
location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff)\$ {
access_log off;
expires 30d;
add_header Pragma public;
add_header Cache-Control "public, mustrevalidate, proxy-revalidate";
break;
}
Add the "break;"
 
12:29 AM
I tried that
but didn't work, so I reverted it
(did also reload nginx)
 
let me think
 
what does the ~* vs ~ do?
 
~* is case insensitive
 
ah
 
you know what? I found the problem
 
12:35 AM
you did?
 
"location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff)\$" => "location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff)$"
The last dollar sign
remove the slash before it
 
let's test it
omg
you're my hero haha
thanks so much :)
if you could update the answer I'll mark it :)
 
I'm doing it
done. you are welcome :)
 
Thanks again :)
 

last day (14 days later) »