DietPi, Nginx proxy manager, phphmyadmin, wordpress backup and others adventures!

Creating a bug report/issue

I have searched the existing open and closed issues

Required Information

  • DietPi version | G_DIETPI_VERSION_CORE=9 G_DIETPI_VERSION_SUB=1 G_DIETPI_VERSION_RC=1 G_GITBRANCH='master' G_GITOWNER='MichaIng'
  • Distro version | bookworm 0
  • Kernel version | 6.1.0-rpi8-rpi-2712
  • Architecture | arm64
  • SBC model | RPI5 or (EG: RPi3)

Additional Information (if applicable)

  • Software title | Wordpress / phpmyadmin
  • Was the software title installed freshly or updated/migrated?
    New install
  • Can this issue be replicated on a fresh installation of DietPi?
    Yes

So, i got a brand new RPI5, and i just install the brand new dietpi for rpi5 update.

And i want to simply :

-Install basic docker and phpmyadmin
-Restore some wordpress website from backup of a old server
-Use nginx proxy manager to put the domain and config the reverse-proxy on this two wordpress site

But i got some problems around that. I will think myself of a intermediate level on linux and server, i know how that work, the only things when it’s gets blurry it’s on the php/nginx configuration things.

So i put the wordpress folders on /var/www and i try to use phpmyadmin to import the old mysql database. But i got some issues :

-Around nginx and nginx proxy manager, they got some conflicts around ports. So i change the nginx.conf to change port (to 3200), but now i try to open phpmyadmin with my IP (even with the new nginx port, like <IPADRESS>:3200/phpmyadmin) and it don’t seem to work. I also try to add a proxy to access it but no success here.

-I install portainer with dietpi-software. Don’t seem i can access it with ip, and domains i put don’t work. What’s weird it’s the fact on another rpi (4) and other dietpi i do the sames steps, and it work easily. Here, no success. Cannot get the logic here.

So, to simple said it : i have to make it work nginx proxy manager + phpmyadmin (but install it install automatically nginx nativelly, causing some conflicts with nginx proxy manager) and config my mysql database with phpmyadmin to restore my two wordpress website.

And after that, i have to config my domains to the two freshly restored wordpress website. But i’m pretty lost on how to do all that. I change nginx port (the native one, not the docker), put wordpress website on /var/www but here i’m kind of stuck. What are the next steps ? How can i access phpmyadmin (no port anywhere and putting /phpmyadmin in custom locations not working)

Can dietpi have another tool to just make proxy and manages multiple domains ? There’s only nginx proxy manager for that ?

Also, it seem dietpi can only install one wordpress, doesn’t support multi-wordpress installation ?

Thanks a lot, dietpi is a very great project

You can use nativ web server like Apache2 or Nginx as revers proxy. Or you have a look to 3rd party tools lika HAProxy

you can use whatever tool you like native apps are container based. If using a 3rd party, ensure you have freed up web server port 80/443. Otherwise your proxy tool is failing.

not within our default configuration. However you should be able to install additional WP instances manually

So, i have successfully set new port for nginx. And access to phpmyadmin.

So now i have to found how to restore my wordpress website. But it don’t seem to work. I restore my wordpress folder on /var/www and i restore the database, with the same name of the old server. But when i try to access :3200/wordpress-website it don’t show nothing, not even a error or thing like that. I don’t know what i do bad…

Also, why portainer still not reachable with :9002 ? I try to reinstall it, still no success

Here’s the log from the containers :

docker logs f96886d28b18
2024/03/11 11:22AM INF github.com/portainer/portainer/api/cmd/portainer/main.go:369 > encryption key file not present | filename=portainer
2024/03/11 11:22AM INF github.com/portainer/portainer/api/cmd/portainer/main.go:392 > proceeding without encryption key |
2024/03/11 11:22AM INF github.com/portainer/portainer/api/database/boltdb/db.go:125 > loading PortainerDB | filename=portainer.db
2024/03/11 11:22AM INF github.com/portainer/portainer/api/internal/ssl/ssl.go:80 > no cert files found, generating self signed SSL certificates |
2024/03/11 11:22AM INF github.com/portainer/portainer/api/chisel/service.go:193 > Generated a new Chisel private key file | private-key=/data/chisel/private-key.pem
2024/03/11 11:22:32 server: Reverse tunnelling enabled
2024/03/11 11:22:32 server: Fingerprint wg2Ci9AtWrNut2i9HmdiTFEF+oueONf8bMRPzBJANFg=
2024/03/11 11:22:32 server: Listening on http://0.0.0.0:8000
2024/03/11 11:22AM INF github.com/portainer/portainer/api/cmd/portainer/main.go:649 > starting Portainer | build_number=35428 go_version=1.20.5 image_tag=linux-arm64-2.19.4 nodejs_version=18.19.0 version=2.19.4 webpack_version=5.88.1 yarn_version=1.22.21
2024/03/11 11:22AM INF github.com/portainer/portainer/api/http/server.go:357 > starting HTTPS server | bind_address=:9443
2024/03/11 11:22AM INF github.com/portainer/portainer/api/http/server.go:341 > starting HTTP server | bind_address=:9000
2024/03/11 11:22AM INF github.com/portainer/portainer/api/cmd/portainer/main.go:369 > encryption key file not present | filename=portainer
2024/03/11 11:22AM INF github.com/portainer/portainer/api/cmd/portainer/main.go:392 > proceeding without encryption key |
2024/03/11 11:22AM INF github.com/portainer/portainer/api/database/boltdb/db.go:125 > loading PortainerDB | filename=portainer.db
2024/03/11 11:22AM INF github.com/portainer/portainer/api/chisel/service.go:198 > Found Chisel private key file on disk | private-key=/data/chisel/private-key.pem
2024/03/11 11:22:42 server: Reverse tunnelling enabled
2024/03/11 11:22:42 server: Fingerprint wg2Ci9AtWrNut2i9HmdiTFEF+oueONf8bMRPzBJANFg=
2024/03/11 11:22:42 server: Listening on http://0.0.0.0:8000
2024/03/11 11:22AM INF github.com/portainer/portainer/api/cmd/portainer/main.go:649 > starting Portainer | build_number=35428 go_version=1.20.5 image_tag=linux-arm64-2.19.4 nodejs_version=18.19.0 version=2.19.4 webpack_version=5.88.1 yarn_version=1.22.21
2024/03/11 11:22AM INF github.com/portainer/portainer/api/http/server.go:357 > starting HTTPS server | bind_address=:9443
2024/03/11 11:22AM INF github.com/portainer/portainer/api/http/server.go:341 > starting HTTP server | bind_address=:9000

how do you install Partainer?

You could check ports available

ss -tulpn | grep LISTEN

With dietpi-software. I saw portainer port here :

tcp LISTEN 0 4096 0.0.0.0:9002 0.0.0.0:* users:(("docker-proxy",pid=71061,fd=4))
Anyone have some knowledge around wordpress ? It’s still the most urgent thing, since it’s for the website of a business of a friend.

I wonder on when nginx it will show ? The one from docker, or the native one ?

you are trying to connect via HTTP or HTTPS?

This I don’t understand. Depends on ports you use within URL and on your setup. If you target native Nginx, you should see information from there.

Both not working. Really it’s make absolutely no sense to me to do the exact same action on the exact same system (just another machine) and it’s just… not working. It’s started to annoy me a bit so i got away from the computer for now (and nginx proxy manager manage to break SSL cert so i have to wait like a day to… make new certs).

Also i’m talking about when you add a site that don’t need port (like wordpress or phpmyadmin). Like i put my wordpress site on /var/www/wordpresswebsite, for example.

So if i want to access to my wordpress, logically, i go to IP-ADRESS/wordpresswebsite ?
Or IP:3200/wordpresswebsite ? Did the path after the ip adress always the name of the folders in /var/www ? And where did you config that, on wp-config ? on the nginx conf ? php ?

Certs should be managed within NPM only. There is absolutely no need to do this within native Nginx as this will just cause issues. Basically whole SSL handling is taken over by NPM now. Native Nginx should stay on plain HTTP.

Locally, you need to call your native Nginx with new port now like http://IP:3200/wordpresswebsite. And yes, it is the folder name within /var/www. At least if this is your www root directory still.

If your webserver listens on port 3002, you need to use IP:3002/wordpress. if it runs on port 80/443 you dont need to do this.
If you proxy it from 3002 to 80, you also can just use IP/wordpress.
So it depends how you config you web server and your reverse proxy / docker-proxy.

https://nginxproxymanager.com/guide/

Easiest wouldbe to use plain nginx, config two virtual hosts for each wordpress site (like /var/www/wordpresssite1.com/html and /var/www/wordpresssite2.com/html. You don’t need to hussle with a reverse proxy then (except for the certs maybe)

even 2 certs can be managed in plain Nginx. Benefit of NPM is to have vhost and cert management done within a Gui and don’t need to deal with config files. But yes, if you know how, all could be done on plain Nginx without the need of a Docker proxy container.

I didn’t found a simple and easy way on dietpi to just… add a domains and put a certs on it and manage the domains on services. That’s why i use nginx proxy manager for reverse proxy and SSL.

Like i said, i know linux, i’m on linux desktop for years now. But nginx/php/SSL configuration and all still seem very obscurs and difficult to me. Like how a nginx.conf work, how you have to make files in php like /php/fpm/pool/conf.d/ for somes stuffs. How mysql is handle.

So maybe you have somes good guides or some wiki ? I just grap pieces on reddit/stackoverflow and sometimes some wiki. But never really found a guide that fit my need.

Before that, i used yunohost, so everything was handle by it, and i have a wordpress backup coming from yunohost so i try to “translate” in a way the backup into dietpi. I successfully import the database, but no success after, it’s a blank page.

I also try to install a fresh wordpress with dietpi-software to see how it work when it’s a new installation. And yeah, i think i have some conflicts around the old wp-config.php and the ngnix.conf (and also php conf maybe ?)

So, yeah, quite a adventure. For just put a reverse proxy into a port for a app, it’s easy. But for me, this kind of setup with /var/www/app + mysql + right config of php/nginx is really hard.

So, thanks for the help !

Bes to setup a new fresh install of WP without restoring any backup. Once this is working move Nginx away from port 80. Afterwards install NPM. I have written a small script to setup NPM in a DietPi way (requires Docker installed from DietPi software)

#!/bin/bash
. /boot/dietpi/func/dietpi-globals

# Check for existing NginxProxyManager container
eval container=$(docker container ls -a | mawk '/jc21\/nginx-proxy-manager/{print $1;exit}')
[[ $container ]] && G_EXEC docker container rm -f "$container"
eval image=$(docker image ls -a | mawk '/jc21\/nginx-proxy-manager/{print $3;exit}')
#[[ $image ]] && G_EXEC docker image rm "$image"
docker volume ls -q | grep -xq 'npm_data' || G_EXEC docker volume create npm_data

# Deploy the NginxProxyManager container
G_DIETPI-NOTIFY 2 'NginxProxyManager will be deployed now. This could take a while...'
G_EXEC_OUTPUT=1 G_EXEC docker run -d -p '80:80' -p '443:443' -p '81:81' --name=npm --restart=always --env 'DB_SQLITE_FILE=/data/database.sqlite' -v 'npm_data:/data' -v 'npm_data:/etc/letsencrypt'  'jc21/nginx-proxy-manager'

Same script can be used to update NPM afterwards :smiley:

As soon as NPM is up, configure the proxy and check if all is working.

Btw: how many domains or sides you like to manage? Just a single WP side or more?

It’s just for two domains name. So two wordpress website yeah.

Still didn’t have any success to restore it. When i import the database, all things break. changing wp-config don’t seem to work, changing some values on the database too.

And i still don’t understand how you simply do redirect like domain.com redirecting to domain.com/wordpress.

It’s weird because a wordpress restoration should be an easy things. But just do a google search redirect you to 157 way of premium plugins backup, i’m kind of blinded here…

Also i use your script, seem to work pretty great !

But there’s really some mystery for me : like why PUBLICIP:80 redirect to the nginx default homepage, but putting the exact same adress on nginx proxy manager doesn’t work ?

Why it doesn’t work to phpmyadmin to add /phpmyadmin in custom location for a domains ?

this can be done with plain Nginx using vhosts. Theoretically no need to use NPM

using NPM vhost allows to adjust the web server root directory per domain. Means, no need to use sub folder.

Btw: this scenario has been discussed on NPM own GitHub including a possible solution How do i forward to a folder? · Issue #104 · NginxProxyManager/nginx-proxy-manager · GitHub

usually this should redirect to NPM and within NPM forwarding depends on your configuration

Within NPN, you would need to use the target system IP like localhost/ 127.0.0.1 (if it’s running on same system) or local network IP if it’s a different host. You can’t use the public DDNS or public external IP. And you need to specify the port your app is running on. In your case, it should be the new port of plain Nginx

Did you checked Nginx server logs if there is anything wrong with database access, maybe you need to set the correct database password specified within WP configuration.

Ok, but why there’s barely any simple guide around that on the net ? If it’s so easy to do ?

NPM kind of drive me mad : sometime localhost not work, but 127.0.0.1 work. Sometime public ip work, but not the local IP, sometimes the opposite (i FINALLY make access to portainer like that)

I really don’t understand why it’s more difficult to just put a reverse proxy to a domain on a program that actually just install and configure the program, been week i just try… to put a domain name on a wordress backup. Really tiring.

Oh, and no logs on /var/nginx/log (because ???), they’re empty. Also you talk about the fact you don’t need sub folder, but also wordpress need to be in /var/www/folder so i don’t really understand this too.

Now, wp-debug don’t give logs, nginx don’t give logs, i modify all i have to do on phpmyadmin…

I’m stuck and don’t know, and where, i can just debug this.

EDIT : So, i finally found how to restore it. So it’s really make a a mess to install whit dietpi-software and using docker to nginx proxy manager. Because you got 2 nginx port, and it’s really hard after to just understand on what nginx port you are.

How can i make my setup more simple around that ?

So, to summarize :

-Have two nginx, one basically… don’t really use it (the :80 port)
-One of my nginx (the :3200) (the native one) have phpmyadmin (cannot have on my domain, have to use public ip) and wordpress.
-I FINALLY access to wordpress, but only the admin (??) and only with the :3200 port. Cannot use the public ip alone (even with a stream configure on nginx proxy manager)

So still don’t show the index.php of my wordpress. Also still don’t put debug.log on /wp-content, for some reasons. So i finally make somes steps, but still don’t understand half of what i do. Maybe i should modify the nginx conf again to put the 80 port again ? To have one “fuse” nginx ?

So now my wordpress admin (not the website still) is accessible like this : http://public_ip:3200/wordpress

When i try to change it to my domain : 404, try to redirect with nginx proxy manager : not working. SSL error also, but certbot not working with dietpi-launcher because “nginx configuration errro”

I… don’t really found this really easy at all.

You make far too many changes to your system without people being able to follow you properly or understand what exactly you are doing.

The easiest way would be to start from the beginning and do it step by step.

But that’s what i do you know ? My installation is fresh : just phpmyadmin, and wordpress with dietpi, and docker

To configure domains, i need nginx proxy manager (because still no easy guide to, not use it and give domains name + certs)

But it’s make 2 nginx port. That’s causing issue after. And you don’t really show me a way to fix that

That’s all. How can i not use two nginx port ?

I restore my wordpress on /var/www/wordpress. I restore my database with phpmyadmin. I need LetsEncrypt to put my domains into my wordpress site.

My wordpress admin is now accessible on publicip:3200/wordpress/ but cannot config to just show the wordpress website with my domains on it.

I just need a guide, or some steps.

So, because it seem hard to understand my setup, i re-re-sumarize here, with logs, and screens.

So i had :

  • a nginx with custom port (3200) on nginx.conf
  • I install docker, and install nginx proxy manager(normal port 80).
  • I restore one wordpress website, for the moment just one. into /var/www/wordpress
  • I restore the database with phpmyadmin. Edit some value to make it accessible with my publicip
    Finally make it to go to my admin of this wordpress site (but, no website, like no index.php). By using publicip:3200/wordpress
    image

I fix phpmyadmin, and i fix portainer

Now, i can modify my url, to my domains name. But it… broke the admin page ?

I cannot give you logs of nginx and wordpress because… there don’t seem to want to make logs (?), even with WP_DEBUG activate, and the logs for nginx are just blank, no lines. What can i do ?

Also, to sumarize my question, and my situation, i will again just put my questions :

Did a SIMPLE setup to just manage domains name, LetsEncrypt certs with a simple GUI exist ? Did there’s only have Nginx proxy manager available ? (You tell me i can use any tool i want, but it was not really my question here : i ask a simple setup. Or a guide.)

So i ask again : did you know a simple guide to just manage domains names and certs with nginx ? (because online with google : you found nginx proxy manager, basically)

I ask that because when you use nginx proxy manager you have two nginx running on our machine, and i found that kind of dumb, and it cause issue after that. So i take a more simple solution around that.

You can simply stay with the NGINX installation done by DietPi software. To generate certificates, use dietpi-letsencrypt and your first WP instance should be up without issues. (keep away to restore for time being). No need for Docker, Portainer or NPM.