我有一个基本的小型Flask应用程序,当在本地运行时,身份验证可以正常工作,但是当我使用高山映像将整个应用程序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似乎工作正常。
答案 0 :(得分:0)
您必须允许容器访问LDAP服务器,在运行容器时,它具有的网络访问受到限制。