Askbot + Nginx + URL Accents = Problem
I install Askbot with Nginx and configure pt_BR locale. All URL with accent broken. After this I install apache(slow) and everything works fine.
I install Askbot with Nginx and configure pt_BR locale. All URL with accent broken. After this I install apache(slow) and everything works fine.
I post the log here because the comments don't allow size.
Yes there is a log:
2012/07/10 11:36:05 [error] 3863#0: *12 FastCGI sent in stderr: "Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/flup/server/fcgi_base.py", line 558, in run
protocolStatus, appStatus = self.server.handler(self)
File "/usr/lib/pymodules/python2.7/flup/server/fcgi_base.py", line 1118, in handler
result = self.application(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 272, in __call__
response = self.get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 146, in get_response
response = debug.technical_404_response(request, e)
File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 294, in technical_404_response
'reason': smart_str(exception, errors='replace'),
File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 123, in smart_str
errors) for arg in s])
File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 124, in smart_str
return unicode(s).encode(encoding, errors)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 27: ordinal not in range(128)" while reading response header from upstream, client: 10.0.0.10, server: ask.alterdata.matriz
Ok, next time please edit the question instead. I think the default encoding in python is wrong - the value of 'encoding' is probably ascii and it's indeed impossible to encode those chars into one-byte codes.
Why works when I change from Nginx to Apache2? If I run the development server (runserver) works too.
Probably b/c of the differences in how python interpreter was started, possibly due to compilation opions in the webserver. Remember that in apache you're probably using mod_wsgi, for nginx - gunicorn, uwsgi or something like that. Look at what actually runs python in your setup. You can use a trick in the .wsgi script sys.stderr.write(...whichever variable you want to test)
to debug. Test what is default encoding in django in those cases. There is some documentation on django site about it.
On the subject of default encoding - take a look here: http://blog.ianbicking.org/illusive-setdefaultencoding.html I've tested on two systems and on one (my mac laptop - I don't have this issue, and another - ubuntu server - I have the issue). It is definitely in the python setup of default character encoding.
To enter a block of code:
Comments
Anything interesting in the access/error logs?
Erick, you can use 'shift-enter' to add new lines in the comments and code can be formatted with markdown - indent lines by 4 chars and precede by one empty. For a long log - just paste into the question body.