%EB%A5%BC%20%EC%84%9C%EB%B2%84%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
NGinx에서 error_page를 사용하여 정적 파일을 서버하는 것이 가능하다는 것을 알고 있지만 UWsgi를 통해 제공되는 로컬(소켓된) Flask 앱에서 URL을 서버하는 것이 가능한지 궁금합니다.
NGinx 구성은 다음과 같습니다.
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) 액세스만 허용하면 작동합니까?
귀하의 통찰력에 감사드립니다.
답변1
교체해 보세요:
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