Discussion:
raise tornado.web.HTTPError
funback
2013-05-16 03:56:30 UTC
Permalink
I run tornado (2.4.1) instance behind nginx, and when something goes wrong
in tornado, i raise a tornado.web.HTTPError(status_code).

I expect this error response is received by nginx, which will render the
corresponding error page (depending on the status_code) to the client's
browser. However, this is not the case, as I see the traceback printed to
the browser, for example:

Traceback (most recent call last):
File
"/home/me/.virtualenvs/project/local/lib/python2.7/site-packages/tornado/web.py",
line 1037, in _execute
self.prepare()
File "/home/me/.virtualenvs/project/my_server.py", line 236, in prepare
raise tornado.web.HTTPError(403)
HTTPError: HTTP 403: Forbidden

I'm not sure if it is related to the fact that i'm running tornado in debug
mode, but I suspect that doesn't matter as the error response should be
sent to nginx with raise HTTPError call. How can I correct this behavior?
--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornado+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Lorenzo Bolla
2013-05-16 08:32:57 UTC
Permalink
Post by funback
I run tornado (2.4.1) instance behind nginx, and when something goes wrong
in tornado, i raise a tornado.web.HTTPError(status_code).
I expect this error response is received by nginx, which will render the
corresponding error page (depending on the status_code) to the client's
browser. However, this is not the case, as I see the traceback printed to
File
"/home/me/.virtualenvs/project/local/lib/python2.7/site-packages/tornado/web.py",
line 1037, in _execute
self.prepare()
File "/home/me/.virtualenvs/project/my_server.py", line 236, in prepare
raise tornado.web.HTTPError(403)
HTTPError: HTTP 403: Forbidden
I'm not sure if it is related to the fact that i'm running tornado in debug
mode, but I suspect that doesn't matter as the error response should be
sent to nginx with raise HTTPError call. How can I correct this behavior?
--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
For more options, visit https://groups.google.com/groups/opt_out.
Are you intercepting errors in nginx?
http://wiki.nginx.org/HttpProxyModule#proxy_intercept_errors

See also:
http://r-ideas.org/blog/nginx-error_page-with-proxy-upstream-easy-as-1-2-3

L.
--
Lorenzo Bolla
http://lbolla.info
--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornado+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Tomasz Prus
2013-05-16 06:45:54 UTC
Permalink
Try to enable:

*proxy_intercept_errors*
*
*
*If you set this to on then nginx will intercept status codes that are
explicitly handled by an error_page directive. Responses with status codes
that do not match an error_page directive will be sent as-is from the
proxied server.*


http://wiki.nginx.org/HttpProxyModule#proxy_intercept_errors

Regards,
Tomasz Prus
--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornado+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
funback
2013-05-18 19:40:39 UTC
Permalink
Thank you guys! Enabling proxy_intercept_errors at the server level
resolves the problem.
Post by funback
I run tornado (2.4.1) instance behind nginx, and when something goes wrong
in tornado, i raise a tornado.web.HTTPError(status_code).
I expect this error response is received by nginx, which will render the
corresponding error page (depending on the status_code) to the client's
browser. However, this is not the case, as I see the traceback printed to
File
"/home/me/.virtualenvs/project/local/lib/python2.7/site-packages/tornado/web.py",
line 1037, in _execute
self.prepare()
File "/home/me/.virtualenvs/project/my_server.py", line 236, in prepare
raise tornado.web.HTTPError(403)
HTTPError: HTTP 403: Forbidden
I'm not sure if it is related to the fact that i'm running tornado in
debug mode, but I suspect that doesn't matter as the error response should
be sent to nginx with raise HTTPError call. How can I correct this behavior?
--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornado+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Loading...