A
A
Anton2014-09-23 14:11:42
Apache HTTP Server
Anton, 2014-09-23 14:11:42

How to configure apache mod_proxy to skip Authorization header with oauth2 token?

Good afternoon.
Now I'm setting up a service that is hidden behind a server with mod_proxy and there was a problem - mod_proxy removes the "Authorization" header
The service itself is written in django and I wrote a small middleware to output the headers to the logger and then compare them. in total, we have on the dev server:
Although this is probably not a django problem, here is the middleware:

import logging
import re
from django.http import HttpResponseRedirect

logger = logging.getLogger(__name__)

class CurrentMetaMiddleware(object):

  def process_request(self, request):
    regex = re.compile('^HTTP_')
    z = dict((regex.sub('', header), value) for (header, value) 
           in request.META.items() if header.startswith('HTTP_'))
    logger.error(z)
    return None

[23/Sep/2014 14:00:32] ERROR [pipelineapi.middleware:14] {'HOST': '127.0.0.1:8000', 'ACCEPT_ENCODING': 'gzip, deflate', 'ACCEPT': '*/*', 'AUTHORIZATION': 'Bearer 9aea813534cb064ab8c6b617c8f23bf68fec3464', 'USER_AGENT': 'python-requests/2.3.0 CPython/2.7.8 Linux/3.14-1-amd64'}

and an absolutely identical request, except for the header values ​​themselves (I get a different token for the request), to production, via mod_proxy:
[23/Sep/2014 14:01:52] ERROR [pipelineapi.middleware:14] {'HOST': 'api.some-server.com', 'ACCEPT': '*/*', 'CONNECTION': 'Keep-Alive', 'USER_AGENT': 'python-requests/2.3.0 CPython/2.7.8 Linux/3.14-1-amd64', 'X_FORWARDED_SERVER': ''api.some-server.com', 'X_FORWARDED_HOST': 'api.some-server.com', 'X_FORWARDED_FOR': '192.168.0.18', 'ACCEPT_ENCODING': 'gzip, deflate'}

As you can see, there is no Authorization header in the second log.
Please tell me why this is happening and how to deal with it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2014-09-23
@widestream

I'll answer myself. It turned out not to be a mod_proxy problem, but a nuance of mod_wsgi :)
in the virtual_host config, add the line:
And restart the server. Voila.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question