0

I know it's possible to server static files using error_page in NGinx, but I was wondering if it was possible to server an url from my local (socketed) Flask app that is served through UWsgi.

Here's the NGinx configuration :

server {
    listen       80;
    server_name www.myproject.com;
    access_log /var/log/nginx/myproject_frontend.access.log;
    error_log /var/log/nginx/myproject_frontend.error.log;

    # Something like :
    error_page 404 uwsgi_pass unix:/tmp/uwsgi_myproject.sock;/errors/404

    location / { try_files $uri @yourapplication; }
    location @yourapplication {
      include uwsgi_params;
      uwsgi_pass unix:/tmp/uwsgi_myproject.sock;
    }
}

Is this possible? Would it work if instead of a socket I would allow a local (127.0.0.1) only access ?

Thank you for your insighs.

Cyril N.
  • 574
  • 1
  • 9
  • 33

1 Answers1

2

Try to replace:

error_page 404 uwsgi_pass unix:/tmp/uwsgi_myproject.sock;/errors/404

by:

error_page 404 /errors/404;

location /errors/ {
    uwsgi_intercept_errors on;
    include uwsgi_params;
    uwsgi_pass unix:/tmp/uwsgi_myproject.sock;
}

source: http://nginx.org/en/docs/http/ngx_http_uwsgi_module.html#uwsgi_intercept_errors

maxxvw
  • 321
  • 1
  • 7