如何解决在NGINX反向代理后面上传文件时,“ AnonymousUserMixin”对象没有属性“ x”
我的Flask应用程序在没有反向代理的情况下独立运行时,可以很好地工作,但是对于生产环境,我希望有一个HTTPS反向代理,因为我计划在开放的Internet上运行此应用程序。除了文件上传,我让代理工作了所有内容。上传文件时,会发生以下错误:
AttributeError: 'AnonymousUserMixin' object has no attribute 'x'
实际的flask-login用户已定义属性x
,但是由于某些原因,在上载文件时,应用程序看不到上载文件的用户确实是经过身份验证的用户。这是我的NGINX反向代理配置:
server {
server_name example.com; # this is set to the actual DNS name
listen 80;
listen [::]:80;
return 301 https://$host$request_uri;
}
server {
server_name example.com; # this is set to the actual DNS name
listen 443 ssl http2;
listen [::]:443 ssl http2;
# enable subfolder method reverse proxy confs
include /config/nginx/proxy-confs/*.subfolder.conf;
# all ssl related config moved to ssl.conf
include /config/nginx/ssl.conf;
location / {
client_max_body_size 20m;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_redirect off;
proxy_pass http://127.0.0.1:5000$request_uri;
}
}
反向代理可以很好地工作,否则,用户登录与应用程序的所有其他功能一起工作。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。