我有一个基本的小型Flask应用程序,当在本地运行时,身份验证可以正常工作,但是当我使用 Alpine 镜像将整个应用程序dockerzise时,身份验证将被破坏。即使输入正确的凭据,我的应用程序也会登录,但会显示一条错误消息,提示“请登录以访问此页面”。
我使用Apache2作为我的反向代理,并使用httpd:alpine作为我的docker镜像。
这是我的 docker 文件
FROM httpd:2.4.38-alpine
RUN apk --update --no-cache add python3 python3-dev apache2 wget ca-certificates make gcc musl-dev py-pip py-virtualenv
COPY ./app_trac/apache2-vhost.conf conf/extra/httpd-vhosts.conf
RUN sed -i -e 's/^#ServerName.*$/ServerName vacation.ps-office.local:80/' conf/httpd.conf
RUN sed -i -e "s|#Include conf/extra/httpd-vhosts.conf|Include conf/extra/httpd-vhosts.conf|g" conf/httpd.conf
RUN cd /usr/local/apache2/modules/
RUN mkdir vacation
COPY ./app_trac/requirements.txt htdocs/app/requirements.txt
RUN pip3 install -r htdocs/app/requirements.txt
RUN pip3 install mod_wsgi
RUN mod_wsgi-express module-config
RUN chmod -R a+rwx htdocs/app
EXPOSE 80
CMD ["httpd", "-D", "FOREGROUND"]
这是我的应用程序的加载和保存用户功能,我正在使用LDAP身份验证。
@login_manager.user_loader
def load_user(user_id):
if user_id in users:
return users[user_id]
return None
@ldap_manager.save_user
def save_user(dn, username, data, memberships):
user = User(dn = dn, username = username, data = data)
users[dn] = user
return user
我基本上在做什么错?我只收到docker的身份验证问题。 Nginx似乎工作正常。
最佳答案
您必须允许容器访问LDAP服务器,在运行容器时,它具有的网络访问受到限制。
也许这可以帮助您LDAP authentication in Docker container
关于docker - 我的flask应用程序身份验证工作正常,但是当我使用 Alpine 图像对整个应用程序进行泊坞验证时,身份验证被破坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54632234/