G
Gati
Guest
I'm trying to deploy a docker-compose stack wich contain a nginx service to manage the others like jenkins or grafana. However, when I target my jenkin service like http://myapp.fr/jenkins, the homepage of the service will redirect to login page at this URL : http://myapp.fr/login?from=/. How I can fix this for all services to prefix with the service name for all pages of it (like http://myapp.fr/jenkins/login?from=/).
My stack looks like this :
My default.conf of nginx is in one of my docker volumes and it looks like this :
When I began the deploy, I use a docker-compose up -d command and all services are running. myapp.fr show the nginx index. However, if I specified the subpath myapp.fr/jenkins, it will be showig a 404 error because of a redirection to http://myapp.fr/login?from=/
How I can fix this for all services to prefix service name for all pages of it (like http://myapp.fr/jenkins/login?from=/).
Thanks
Answer for: "Nginx Reverse Proxy on docker containers : 404 redirections"...
My stack looks like this :
Mã:
version: "3.7"
services:
## NGINX ##
web:
image: nginx
container_name: myapp_nginx
volumes:
- ./config/nginx/templates:/etc/nginx/templates
- ./config/nginx/include.d:/etc/nginx/include.d
- ./config/nginx/www:/var/www/certbot
ports:
- "80:80"
- "443:443"
environment:
- NGINX_HOST=myapp.fr
- NGINX_PORT=80
networks:
- myapp
## JENKINS ##
jenkins:
build:
context: ./dockerfile/jenkins
dockerfile: Dockerfile
container_name: myapp_jenkins
hostname: jenkins.myapp.fr
privileged: true
user: root
ports:
- 8080:8080
- 50000:50000
volumes:
- ~/jenkins:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/local/bin/docker:/usr/local/bin/docker
restart: always
networks:
- myapp
## GRAFANA ##
grafana:
image: grafana/grafana-enterprise:8.2.0
container_name: myapp_grafana
hostname: grafana.myapp.fr
ports:
- 3000:3000
user: "104"
networks:
- myapp
networks:
myapp:
driver: bridge
My default.conf of nginx is in one of my docker volumes and it looks like this :
Mã:
server {
listen 80;
listen [::]:80;
server_name myapp.fr;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /jenkins/ {
proxy_set_header Host $host;
add_header Access-Control-Allow-Origin '*';
proxy_pass http://jenkins.myapp.fr:8080/;
}
location /grafana/ {
proxy_set_header Host $host;
add_header Access-Control-Allow-Origin '*';
proxy_pass http://grafana.myapp.fr:3000/;
}
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Access-Control-Allow-Origin';
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
When I began the deploy, I use a docker-compose up -d command and all services are running. myapp.fr show the nginx index. However, if I specified the subpath myapp.fr/jenkins, it will be showig a 404 error because of a redirection to http://myapp.fr/login?from=/
How I can fix this for all services to prefix service name for all pages of it (like http://myapp.fr/jenkins/login?from=/).
Thanks
Answer for: "Nginx Reverse Proxy on docker containers : 404 redirections"...