0

I have an url like this: "mydomain.com/dictionary/Elastizit%E4t.htm".

I know the url sucks, I'm migrating a very old site and for SEO reasons we need to make redirects from the old urls to the new ones. So for the time being I have something like 14000 URLs like this and I need to redirect them to their new companions or follow some redirect rules defined in my django/python webserver.

If the URL would hit my python app, I'd be able to handle it like this:

>>> from urllib.parse import unquote
>>> unquote('Elastizit%E4t.htm', encoding='latin')
'Elastizität.htm'

However, nginx itself breaks with a 400 Bad Request.

My Nginx config is very simple:

server {
    listen 80;
    server_name mydomain.com;
    client_max_body_size 10M;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /srv/mydomain.com/shared/public;
    }

    location / {
        auth_basic "Restricted";
        auth_basic_user_file /etc/nginx/.htpasswd;

        include proxy_params;
        proxy_pass http://unix:/srv/mydomain.com/current/gunicorn.sock;
    }
}

It's important to me, that the webserver itself utf-8, I don't want to have iso-8859-1 and friends as my default encoding.

6
  • What do your nginx debug logs say?
    – womble
    Oct 28, 2015 at 9:32
  • Interestingly, the debugging log contains the correct encoding ... dpaste.de/OomL
    – shredding
    Oct 28, 2015 at 10:50
  • 1
    recv() not ready (11: Resource temporarily unavailable) while nginx is trying to talk to gunicorn... This has nothing to do with character encoding. Oct 28, 2015 at 12:30
  • Hm, I'm not sure if that really belonged together. If I now do it again, the debug log does not fill at all.
    – shredding
    Oct 28, 2015 at 13:05
  • oh, it belongs together, sorry. there is a debug log. However, my webapp has a 400 Page that isn't shown. Therefore it should happen in gunicorn, which in turn has nothing in it's logs.
    – shredding
    Oct 28, 2015 at 13:06

1 Answer 1

0

It turned out to be a bug in most python frameworks, aka https://code.djangoproject.com/ticket/25623 and https://github.com/Pylons/pyramid/issues/2047.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .