Closed jonathanmmm closed 3 years ago
What version are you using?
I am using: phpmyadmin 5.1.1 (from webinterface)
in docker-compose I use:
image: phpmyadmin
Thank you !
I think you meant "in the docker-compose network" for "nginx is inside a container and has -p 80:8080 to the outside world"
version: "3"
services:
phpmyadmin-frontend:
image: phpmyadmin:latest
environment:
PMA_ABSOLUTE_URI: http://localhost:8075/mysql/
nginx:
image: nginx:alpine
volumes:
- "./nginx.conf:/etc/nginx/conf.d/nginx.conf"
ports:
- "8075:8080"
server {
listen 8080;
server_name localhost;
location /mysql {
rewrite /mysql/([^/]+) /$1 break;
set $upstream_phpmyadmin phpmyadmin-frontend:80;
proxy_pass http://upstream_phpmyadmin/;
proxy_pass_header Content-Type;
}
}
I think http://upstream_phpmyadmin/;
was meant to be http://$upstream_phpmyadmin/;
and the rewrite
regex was not working
Source: https://stackoverflow.com/a/47447211/5155484
.
├── docker-compose.yml
└── nginx.conf
0 directories, 2 files
version: "3"
services:
phpmyadmin-frontend:
image: phpmyadmin:latest
container_name: phpmyadmin-frontend
environment:
PMA_ABSOLUTE_URI: http://localhost:8075/mysql/
nginx:
image: nginx:alpine
volumes:
- "./nginx.conf:/etc/nginx/conf.d/nginx.conf:ro"
ports:
- "8075:8080"
server {
listen 8080;
server_name localhost;
set $upstream_phpmyadmin phpmyadmin-frontend:80;
location /mysql {
resolver 127.0.0.11; # Docker internal DNS
rewrite ^/mysql(/.*)$ $1 break;
proxy_pass http://$upstream_phpmyadmin;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
Url to access: http://localhost:8075/mysql/
(last /
is very important)
Oh, the last / could be the factor, I never tried it that way, thanks.
Great, it works. I had to put the set $upstream_phpmyadmin outside the location, inside I got:
2021/06/14 18:12:47 [warn] 32#32: *23 using uninitialized "upstream_phpmyadmin" variable, client: 10.8.0.2, server: 10.8.0.1, request: "GET /mysql/ HTTP/1.1", host: "10.8.0.1"
2021/06/14 18:12:47 [error] 32#32: *23 invalid URL prefix in "http://", client: 10.8.0.2, server: 10.8.0.1, request: "GET /mysql/ HTTP/1.1", host: "10.8.0.1"
and yes, there was a $ missing, but tried before correctly.
Many thanks :-)
@ibennetch should we add this example to the documentation?
Hi,
I found this one https://github.com/phpmyadmin/docker/issues/101 but this is not about nginx. and tried many different ways, but I can't get it right
The PMA_URI is in docker-compose.yml
- PMA_ABSOLUTE_URI=http://10.8.0.1/mysql/
nginx is inside a container and has -p 80:8080 to the outside world
I get the following error in browser (chromium) console: crbug/1173575, non-JS module files deprecated.
sometimes I got 404 forbidden or not found, e.g. with css/js, tried a lot and couldn't get it to work.
Does somebody know how to solve this? I try the same setup with an phplapadmin container and it didn't work either.
without subfolder it works.