我需要在我的小型 Python 应用程序(只有一个脚本)中从 nginx + uWSGI 获取身份验证数据。身份验证必须在 Web 服务器端(例如 nginx,nginx.conf 中的基本身份验证)实现,而不是在 Python 应用程序中实现,这一点很重要!所以,没有中间件或类似的东西会有所帮助......
我想 uWSGI 必须通过其 API 或 smth 将此数据发送到我的 Python 应用程序..
如何在 Python 脚本中获取这些数据? 我需要类似的东西
$_SERVER['PHP_AUTH_USER']
在 PHP 中。
uWSGI session :
[uwsgi]
socket = /tmp/uwsgi.sock
processes = 4
master = true
module = myapp
harakiri = 30
cache = false
daemonize = /var/log/uwsgi.log
nginx 配置:
server {
listen 8080;
server_name _;
location / {
include uwsgi_params;
uwsgi_pass unix:///tmp/uwsgi.sock;
uwsgi_cache off;
}
}
谢谢!
最佳答案
尝试添加
uwsgi_param REMOTE_USER $remote_user;
在 nginx 配置中
您将在environ['REMOTE_USER']中找到用户名
关于python - Python中nginx和uWSGI获取认证数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11180795/