tiagorvmartins / portanexus

A mobile connection for your Portainer instance
MIT License
46 stars 0 forks source link

Please make it available o playstore can't side load #1

Open spupuz opened 4 weeks ago

spupuz commented 4 weeks ago

Please make it available o playstore can't side load

tiagorvmartins commented 3 weeks ago

Hey @spupuz thank you for your interest! Unfortunately the app is not ready yet for a playstore release, However I will keep you updated and let you know once it's published!

tiagorvmartins commented 2 weeks ago

Hey @spupuz, the updated main branch have now instructions for hosting the application as a PWA, which might help with this issue, you should be able to host the website on your infra and then access it from your mobile and install as app from the browser.

Until later time it won't be on play store, so gave this PWA as an option for iOS but also for anyone that can't sideload the apk on Android.

Hope it helps!

spupuz commented 2 weeks ago

Hey @spupuz, the updated main branch have now instructions for hosting the application as a PWA, which might help with this issue, you should be able to host the website on your infra and then access it from your mobile and install as app from the browser.

Until later time it won't be on play store, so gave this PWA as an option for iOS but also for anyone that can't sideload the apk on Android.

Hope it helps!

can be hosted like a docker app?

tiagorvmartins commented 2 weeks ago

Yes it can, a sample compose is provided on README.md

Let me know if you find issues or your need help

spupuz commented 2 weeks ago

where this goes?

  header @cors Access-Control-Allow-Origin "*"

  # Handle OPTIONS requests
  @options {
    method OPTIONS
  }

  header @options Access-Control-Allow-Origin "*"
  header @options Access-Control-Allow-Headers "Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Api-Key"
  header @options Access-Control-Allow-Methods "GET, POST, OPTIONS"
  respond @options "" 200
}
spupuz commented 2 weeks ago

there is a big problem too i use portainer in bridged mode and can connect with portanexus docker to another container :/ or at least it is possible but there a big list of configuration to do i did it only for pihole

tiagorvmartins commented 2 weeks ago

where this goes?

  header @cors Access-Control-Allow-Origin "*"

  # Handle OPTIONS requests
  @options {
    method OPTIONS
  }

  header @options Access-Control-Allow-Origin "*"
  header @options Access-Control-Allow-Headers "Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Api-Key"
  header @options Access-Control-Allow-Methods "GET, POST, OPTIONS"
  respond @options "" 200
}

That's a configuration for portainer to use on your reverse proxy (in that case Caddy), when using PortaNexus as PWA (docker container), to allow CORS. Caddy is a web server that can act as a reverse proxy.

Let me ask you, how do you normally access your Portainer instance? Do you have some reverse proxy? like nginx or so?

Or you only access Portainer from your local network?

Regarding pihole, I have never used it, so can't help much on that currently, sorry

spupuz commented 2 weeks ago

I use via tailscale or local la not over reverse proxy

tiagorvmartins commented 2 weeks ago

I am using tailscale too, you can have caddy hosting your portainer and portanexus, and without doing any kind of port forwarding.

Here is an example of Caddy for this to work:

portainer.yourdomain.com {
  reverse_proxy http://127.0.0.1:9000
  import cloudflare

  @cors {
    method GET POST
  }

  header @cors Access-Control-Allow-Origin "*"

  # Handle OPTIONS requests
  @options {
    method OPTIONS
  }

  header @options Access-Control-Allow-Origin "*"
  header @options Access-Control-Allow-Headers "Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Api-Key"
  header @options Access-Control-Allow-Methods "GET, POST, OPTIONS"
  respond @options "" 200
}

portanexus.yourdomain.com {
  reverse_proxy http://127.0.0.1:33946
  import cloudflare
}

And the requirements for this is having the cloudflare agent and tailscale installed on the machine where your docker containers are running. The statement 'import cloudflare' handles the request of SSL certificates for the each wildcard domain.

spupuz commented 2 weeks ago

Don't have cloud flare agent. Is there a compose to manage this?

tiagorvmartins commented 2 weeks ago

Yes there is, you can follow the following approach if you prefer, simpler for lan access / tailscale.

Add the following file on directory where your docker-compose.yml will be, This will support add CORS support for Portainer.

events {
    worker_connections 1024;  # Set the maximum number of connections for each worker process
}

http {
    server {
        listen 80;

        location / {
            proxy_pass http://portainer_test:9000;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;

            if ($request_method = 'OPTIONS') {
                add_header 'Access-Control-Allow-Origin' '*';
                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
                add_header 'Access-Control-Allow-Headers' 'Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Api-Key';
                add_header 'Access-Control-Max-Age' 3600;
                add_header 'Content-Length' 0;
                add_header 'Content-Type' 'text/plain charset=UTF-8';
                return 204;
            }

            if ($request_method = 'GET') {
                add_header 'Access-Control-Allow-Origin' '*';
            }

            if ($request_method = 'POST') {
                add_header 'Access-Control-Allow-Origin' '*';
            }
        }
    }
}

Then add the following docker-compose.yml to the same directory:

services:
  portanexus-web:
    image: tiagorvmartins/portanexus-web:v0.1.1
    ports:
      - "8087:80"
  portainer_test:
    image: portainer/portainer-ce:latest
    container_name: portainer_test
    restart: always
    ports:
      - "9002:9000"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./portainer-data:/data
  nginx:
    image: nginx:latest
    ports:
      - "8088:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    depends_on:
      - portainer_test

Go to the portainer instance that this compose launched (http://your-local-ip:9002) and generate an Access Key. Then access portanexus at (http://your-local-ip:8087) and use:

portainer host:

key:

Let me know if it helps you