Wednesday, 15 June 2011

How to serve specific static files with nginx? -


itemprop = "text">

/ api / lang? There are queries like Lang = en , which I want to serve with nginx as /server/i18n-angular/en.json . How can I do this?

I have the following directory structure:

  / public / /server/i18n-angular/en.json  

I have The following is the configuration, but NGNX states that it is wrong to use Index Directive at that time.

  server {root / public ... location / API / lang {if ($ Args ~ * "\? Lang = (. +)") {Set $ ​​language $ 1; Index ../server/i18n-angular/$language.json; }}}}  

Which direction should I use instead of index ?

"index" specifies the index file to display a folder, so you do not need it is.

You need to "rewrite" instead:

  space / API / lang {aka / server / IILN-angle; If ($ Argge ~ * "\? Lang = (. +)") {Set $ ​​language $ 1; Rewrite ^ / (. *) $ / $ Language.json; }}  

No comments:

Post a Comment