I'm trying to pass all traffic at location ^/[a-z0-9]{24}$
to index.html at a different root directory. I have my config set up like so:
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
root /Users/me/sites/store_front/static;
index index.html;
try_files $uri $uri/ $uri.html =404;
location ~ "^/[a-z0-9]{24}$" {
alias /Users/me/web_app/static;
try_files $uri index.html;
}
}
For some reason when I curl this url I get a 404:
$ curl -I https://example.com/55c898e7faa137f42409d403
HTTP/1.1 404 Not Found
Server: nginx/1.8.0
Content-Type: text/html; charset=UTF-8
Content-Length: 168
Connection: keep-alive
Does anyone know how to get this alias working?
update:
One caveat to this is that I need all the relative urls in index.html to load correctly:
<link href="/styles/main.css" rel="stylesheet" type="text/css"
<script src="/javascript/main.js"></script>
These files actually exist in the web_app
directory but nginx tries to load them from store_front
Thanks