How can I have phpmyadmin under my Nginx reverse proxy ?


I already have an nginx reverse proxy that I use for all kind of services. Now I need to add MariaDB and phpmyadmin to my services. According to the docs, the base phpmyadmin path is


. But I can’t manage to add it to my reverse proxy. I tried this :

location /phpmyadmin/ {
    proxy_pass         http://localhost:80/phpmyadmin/;
    proxy_http_version 1.1;
    proxy_set_header   Upgrade $http_upgrade;
    proxy_set_header   Connection keep-alive;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_set_header   X-Forwarded-Host $http_host;

But it doesn’t seem to be working, I have a 404 error.
Looking a bit further, it appears phpmyadmin is using its own apache2 server, that got installed at the same time. I guess this couldn’t work because apache and nginx are both trying to use the same port. So my question is :

Should I make phpmyadmin run on nginx instead of apache ? If yes, how ?
If no, is it possible to make a reverse proxy in my nginx config to phpmyadmin’s apache ? How ?

Thanks in advance for any answer, have a great day

There shouldn’t be any need to do a proxy configuration. Phpmyadmin is a web server application and should be already reachable via Nginx by default.

Nginx is running on port 80/443 and doing your proxy configuration will end up in a loop pointing to Nginx itself.

I forgot to say that my goal is to make phpmyadmin accessible from the outside of my network. That’s why I’m looking to set it behind my nginx reverse proxy. But it doesn’t seem to work, maybe because by default phpmyadmin is on port 80 and not another port.

I guess than you just have to portforward port 80 in your router and you’re good to go, unless you run more than one webserver on different devices in your LAN, which should be accessible from the internet.

I guess there is a misunderstanding still. phpmyadmin is not an own application. It is nothing else than a web site hosted by a web server. I you case, it should be Nginx you use already as revers proxy. Therefore, of course it is running on port 80, as Nginx is running on port 80. That’s the reason why no revers proxy should be needed as phpmyadmin web site should be reachable already.

Unfortunately, that’s the case. I already have an Nginx server on my port 80.

And exactly this Nginx is already serving your phpmyadmin. There is no other web server. Phpmyadmin is a web server based app and is provided by your Nginx.

I am having a “404 error not found” when I try to access phpmyadmin on my domain. I checked that phpmyadmin and mariadb are properly installed. The services are up and running.

Can you reach it with the local IP of the device?
Do you can reach other stuff you habe running on that server (if you have other)?

I am currently not on the same network as the pi and won’t be able to access it for a few months.
Yes, I have a lot of other stuff running on it and everything is perfectly accessible.

you are using a plain Nginx or something like Nginx Proxy Manager? Your web server root is still /var/www? Can you share your proxy configuration files and web server config files? You could remove or overwrite domain information.