我有一个带有令牌身份验证的Django应用程序,我通过Apache2提供它。当我用域名向服务器发出授权请求时,它返回401未经授权的HTTP错误。当我使用ip:port执行此操作时,它返回成功。将相同的令牌发送到服务器。是什么导致的呢?apache服务器是否与此相关?
这是我的apache配置:
<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>
Apache默认不传递Authorization
标头,您需要在VirtualHost配置中添加以下内容并重新启动Apache
WSGIPassAuthorization On