I have Jenkins behind NGINX reverse proxy, both docker containers are in the same network thanks to docker compose. The only entrance to Jenkins server is through NGINX which expose 80 port. Once the request reach NGINX container then it redirects to Jenkins.
I don't get a successful response, but without NGINX reverse proxy everything works fine. How Can I solve this?
In addition, you can find some additional files like nginx default.conf and docker-compose.yml https://github.com/orbismobile/docker-nginx-jenkins-android
After setting up them:
- NGINX user basic auth: user1 - android(password)
- Jenkins admin user: user2 - ios(password)
I've tried this
curl -u user1:android http://localhost:8080/api/json?pretty=true
curl -u user2:ios http://localhost:8080/api/json?pretty=true
curl -U user2:ios -u carlos1:android http://localhost:8080/api/json?pretty=true
JENKINS DOCKERFILE
FROM jenkins/jenkins:latest
ENV JENKINS_OPTS="--prefix=/jenkins"
NGINX DOCKER FILE
FROM nginx:latest
# Install a password file creation utility to create username-password pairs
RUN apt-get update; apt-get install -y --no-install-recommends apache2-utils
RUN mkdir /etc/apache2; cd /etc/apache2; touch .htpasswd
DOCKER-COMPOSE.YAML
version: '3'
services:
jenkinsservice:
build: ./jenkins-service
volumes:
- jenkinshomevol:/var/jenkins_home
nginxservice:
build: ./nginx-service
ports:
- "80:80"
volumes:
- ./nginx-service/conf.d:/etc/nginx/conf.d
- ./nginx-service/html:/usr/share/nginx/html
depends_on:
- jenkinsservice
volumes:
jenkinshomevol:
I expect the 200 OK HTTP CODE, but the actual output is 403 FORBIDDEN HTTP CODE from Jenkins with this body --> Authentication required - You are authenticated as: anonymous