我知道可以在NGinx中使用error_page来服务静态文件,但是我想知道是否可以通过UWsgi提供的本地(插入式)Flask应用程序来服务URL。
这是NGinxconfiguration:
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; } }
这可能吗? 它会工作,而不是一个套接字,我会只允许本地(127.0.0.1)访问?
谢谢你的支持。
尝试replace:
error_page 404 uwsgi_pass unix:/tmp/uwsgi_myproject.sock;/errors/404
通过:
error_page 404 /errors/404; location /errors/ { uwsgi_intercept_errors on; include uwsgi_params; uwsgi_pass unix:/tmp/uwsgi_myproject.sock; }
来源: http : //nginx.org/en/docs/http/ngx_http_uwsgi_module.html#uwsgi_intercept_errors