Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Django Token Authentication doesn't work when I access to server via domain name

I have a Django application with token authentication and I serve it via Apache2. When I do my auth required requests to the server with the domain name it returns with 401 Unauthorized HTTP error. When I do it with ip:port, it returns success. Same token is sent to the server. What might cause that? May apache server be related to this?

Here is my apache config:

<VirtualHost *:80>
        ServerAdmin ...
        ServerName semanticspace.io
        ServerAlias www.semanticspace.io
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        Alias /static /home/cuneyttyler/knowledgebase/knowledge-base-django/static
        <Directory /home/cuneyttyler/knowledgebase/knowledge-base-django/static>
                Require all granted
        </Directory>

        Alias /media /home/cuneyttyler/knowledgebase/knowledge-base-django/media
        <Directory /home/cuneyttlyer/knowledgebase/knowledge-base-django/media>
                Require all granted
        </Directory>

        <Directory /home/cuneyttyler/knowledgebase/knowledge-base-django/knowledgebase_python>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        WSGIDaemonProcess knowledge-base-django python-path=/home/cuneyttyler/knowledgebase/knowledge-base-django python-home=/home/cuneyttyler/knowledgebase/knowledge-bas>
        WSGIProcessGroup knowledge-base-django
        WSGIScriptAlias / /home/cuneyttyler/knowledgebase/knowledge-base-django/knowledgebase_python/wsgi.py
</VirtualHost>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Apache does not pass on the Authorization header by default, you need to add the following to your VirtualHost config and restart Apache

WSGIPassAuthorization On
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading