0

Here's what I would like to accomplish:

  1. All requests to /api/... should be directed to a reverse proxy
  2. All requests to /static/... should be served from /html/static/pub
  3. All other requests should be served from /html/app/pub OR fall back to /html/app/pub/index.html

Changing the folder structure of /html is not currently an option.

Here's what my location blocks currently look like:

root /html/app/pub/;

location /api/ {
  # proxy details...
}

location ~* /static/(.*) {
  try_files /html/static/pub/$1 =404;
}

location / {
  try_files $uri /index.html;
}

With this setup, requirements (1) and (3) are fulfilled, but (2) is not. Any request made to any path within /static comes back with HTTP 404. There are no errors in the nginx log, the request is just logged as Not Found.

I've tried many different permutations, each of which broke at least one of the requirements; this is the closest I've gotten to what I'm looking for. I have scoured all the articles I could google (90% of which use literally the same example snippets), but I couldn't find a solution to this.

Thanks in advance.

Máté Safranka
  • 121
  • 1
  • 6

1 Answers1

1

Solved:

location ~* /static/(.*) {
  root /html/static/pub/;
  try_files /$1 =404;
}
Máté Safranka
  • 121
  • 1
  • 6