static file url rewrite

Wee Sritippho wee.s at forest.go.th
Wed Dec 4 10:42:39 UTC 2019


Hi all,

I'm using nginx unit to serve my Vue.js app and trying to redirect every
uri (except '/api/*') to the app.

In nginx, I can do something like this:

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

How can I do the same using nginx unit?

Thank you,
Wee.

My current config (which results in 404 Error when trying to access
every uri except '/' and '/api/*'):
{
        "listeners": {
                "*:5000": {
                        "pass": "routes"
                }
        },

        "applications": {
                "flask_app": {
                        "type": "python 3",
                        "path": "/app/",
                        "home": "/venv/",
                        "module": "app"
                }
        },

        "routes": [
                {
                        "match": {
                                "uri": "/api/*"
                        },

                        "action": {
                                "pass": "applications/flask_app"
                        }
                },
                {
                        "action": {
                                "share": "/app/static/"
                        }
                }
        ]
}


More information about the unit mailing list