I’m encountering a 401 Unauthorized error when attempting to access the BaseX REST API through my Docker container. I’ve included the Schematron module during the build process. Here’s my setup:
FROM openjdk:17-alpine
RUN apk add bash curl
ENV BASE_DIR=/opt/basex
ENV JAVA_HOME=/usr/lib/jvm/openjdk-17
RUN mkdir -p $BASE_DIR
RUN addgroup -S basex && adduser -S -G basex basex
COPY basex-*.zip $BASE_DIR
RUN unzip $BASE_DIR/basex-*.zip -d $BASE_DIR
RUN chown -R basex:basex $BASE_DIR
COPY .basex $BASE_DIR/etc/ (Check if this is necessary)
EXPOSE 1984 80
WORKDIR $BASE_DIR
USER basex
# Download and extract Schematron module
RUN curl -L https://github.com/Schematron/schematron-basex/raw/master/dist/schematron-basex-1.2.xar -o /tmp/schematron-basex-1.2.xar &&
unzip /tmp/schematron-basex-1.2.xar -d $BASE_DIR/basex/repo &&
rm /tmp/schematron-basex-1.2.xar
CMD ["bash", "-c", "/opt/basex/basex/bin/basexhttp", "-Uadmin"]
Docker run command
docker run -d -p 80:80 -p 1984:1984 --name basex-container basex-image
Error Messages:
curl -i http://localhost:80/rest/
HTTP/1.1 401 Unauthorized
curl -i http://admin:admin@localhost:80/rest/factbook
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="BaseX"
Content-Type: text/plain;charset=utf-8
Content-Length: 21
Server: Jetty(11.0.22)
Access denied: admin
Questions:
-
Are there any potential configuration errors in the Dockerfile that might cause authorization issues?
-
Could there be a configuration issue in BaseX itself preventing access even with correct credentials?