From 4d7e62d8c078c8831a51fa1a9aa8a06243f66fcc Mon Sep 17 00:00:00 2001 From: GCH Date: Mon, 18 May 2026 08:01:36 +0200 Subject: [PATCH] =?UTF-8?q?Initial=20commit.=20Tilf=C3=B8jet=20filer=20fra?= =?UTF-8?q?=20Codeberg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 51 ++++++++++++++++++++++++++++++ it-tools/docker-compose.yaml | 13 ++++++++ portainer-ssl-with-npm/copycert.sh | 11 +++++++ portainer-ssl-with-npm/crontab.md | 5 +++ 4 files changed, 80 insertions(+) create mode 100644 it-tools/docker-compose.yaml create mode 100644 portainer-ssl-with-npm/copycert.sh create mode 100644 portainer-ssl-with-npm/crontab.md diff --git a/README.md b/README.md index e69de29..7e4eea9 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,51 @@ +This repo contains various scripts and tweaks for Portainer and other relevant containers. + +--- + +# Activate SSL via NPM (Nginx Proxy Manager) for Portainer + +1. Set up NPM as a container and generate SSL certificates. + +2. Create a script to copy the certificates to the host, ensuring Portainer loads them on reboot. + - Copy script: [copycert.sh](./portainer-ssl-with-npm/copycert.sh) + - Ensure the script is executable: `chmod +x copycert.sh` + +3. Set up a crontab to automate the copy process. + - Crontab setup: [crontab.md](./portainer-ssl-with-npm/crontab.md) + +4. Start/restart Portainer with the SSL certificates. + - `--replace` swaps the container with the new settings — nothing is deleted. +``` +sudo podman run -d -p 8000:8000 -p 9443:9443 --replace --name portainer --restart=always --privileged -v /run/podman/podman.sock:/var/run/docker.sock -v portainer_data:/data -v /etc/ssl/certs/portainer/:/certs portainer/portainer-ce:lts --tlscert /certs/fullchain.pem --tlskey /certs/privkey.pem +``` + +--- + +# Expose Gitea via NPM (Nginx Proxy Manager) + +1. Create a shared network so NPM and Gitea can communicate internally. + +2. Add the `proxy` network to both stacks in Portainer. + - NPM compose — add `proxy` network to the `app` service. + - Gitea compose — add `proxy` network to the `server` service (not `db`). + +3. Set `ROOT_URL` in Gitea's `app.ini` to use HTTPS. +```ini + ROOT_URL = https://git.example.com/ +``` +4. Configure NPM Proxy Host. + - Forward Hostname/IP: `gitea-stack` + - Forward Port: `3000` + - Websockets Support: enabled + - SSL: Force SSL enabled + +# Expose IT Tools via NPM (Nginx Proxy Manager) + +1. Add the `proxy` network to the IT Tools stack. + - IT Tools compose — add `proxy` network to the `it-tools` service. +2. Configure NPM Proxy Host. + - Forward Hostname/IP: `it-tools-stack` + - Forward Port: `80` (container port, not host port) + - SSL: Force SSL enabled + +> **Note:** Always use the container's internal port in NPM, not the host port. NPM communicates directly with the container via the shared network. \ No newline at end of file diff --git a/it-tools/docker-compose.yaml b/it-tools/docker-compose.yaml new file mode 100644 index 0000000..eb23ba7 --- /dev/null +++ b/it-tools/docker-compose.yaml @@ -0,0 +1,13 @@ +services: + it-tools: + image: 'corentinth/it-tools:latest' + ports: + - '8080:80' + restart: unless-stopped + container_name: it-tools-stack + networks: + - proxy + +networks: + proxy: + external: true diff --git a/portainer-ssl-with-npm/copycert.sh b/portainer-ssl-with-npm/copycert.sh new file mode 100644 index 0000000..62481b3 --- /dev/null +++ b/portainer-ssl-with-npm/copycert.sh @@ -0,0 +1,11 @@ +#!bin/bash +#Assuming the NPM conf is at $baselocation +#This script can be placed at /etc/opt/scripts/ +umask 077 +baselocation="/etc/opt/docker_conf/nginxproxymanager-stack/data/letsencrypt/live/" + +latestnpmfolder=$(ls -t "$baselocation"|head -n 1) +certlocation=$baselocation$latestnpmfolder/ +pushd $certlocation +cp -L -rf fullchain.pem /etc/ssl/certs/portainer/ +cp -L -rf privkey.pem /etc/ssl/certs/portainer/ \ No newline at end of file diff --git a/portainer-ssl-with-npm/crontab.md b/portainer-ssl-with-npm/crontab.md new file mode 100644 index 0000000..1046f6c --- /dev/null +++ b/portainer-ssl-with-npm/crontab.md @@ -0,0 +1,5 @@ +# Crontab script as follows +``` +0 * * * * sh /etc/opt/scripts/copycert.sh >/dev/null 2>&1 +@reboot sh /etc/opt/scripts/copycert.sh >/dev/null 2>&1 +``` \ No newline at end of file