HeyPuter / puter

🌐 The Internet OS! Free, Open-Source, and Self-Hostable.
https://puter.com
GNU Affero General Public License v3.0
26.63k stars 1.78k forks source link

Puter changes app urls on self-hosted instance to site.puter.localhost #784

Open Patt92 opened 1 month ago

Patt92 commented 1 month ago

Issue Description I have an app made with the index url: https://elements-6nvxf03mqbr-tx7qc.puter.mydomain.de

Puter itself runs at https://puter.mydomain.de and provides also https://api.puter.mydomain.de

Steps to Reproduce

  1. Create a docker container. I use a composer file setup.
version: "3.8"
services:
  puter:
    container_name: puter
    image: ghcr.io/heyputer/puter:latest
    pull_policy: always
    # build: ./
    restart: unless-stopped
    ports:
      - '4100:4100'
    environment:
      # TZ: Europe/Paris
      # CONFIG_PATH: /etc/puter
      PUID: 1000
      PGID: 1000
      mode: production
    volumes:
      - /opt/puter/config:/etc/puter
      - /opt/puter/data:/var/puter
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://172.18.0.2:4100/test || exit 1
      interval: 60s
      timeout: 2s
      retries: 2
      start_period: 20s
    networks: 
      - puter

networks:
  puter:
      name: puter
      driver: bridge
      driver_opts:
        com.docker.network.bridge.name: puternet
      ipam:
        driver: default
        config:
          - subnet: 172.18.0.0/16
            ip_range: 172.18.0.0/24
            gateway: 172.18.0.1
  1. Edit the config.json to reflect my dns record and get rid of "Invalid Host Header"
{
    "config_name": "generated default config",
    "env": "dev",
    "nginx_mode": true,
    "server_id": "OracleVM",
    "http_port": "4100",
    "domain": "puter.mydomain.de",
    "protocol": "https",
    "contact_email": "patt@duck.com",
    "services": {
        "database": {
            "engine": "sqlite",
            "path": "puter-database.sqlite"
        },
        "thumbnails": {
            "engine": "purejs"
        },
        "file-cache": {
            "disk_limit": 163840,
            "disk_max_size": 163840,
            "precache_size": 163840,
            "path": "./file-cache"
        }
    },
    "cookie_name": "redacted",
    "jwt_secret": "redacted",
    "url_signature_secret": "redacted",
    "mode": "production",
    "pub_port":443,
    "": null
}
  1. make it available via a reverse proxy (Nginx)
server {
    listen 443 ssl;
    listen 172.17.0.14:443 ssl;
    server_name puter.mydomain.de api.puter.mydomain.de *.puter.mydomain.de puter.localhost *.puter.localhost;
    ssl_certificate /etc/webmin/letsencrypt-cert.pem;
    ssl_certificate_key /etc/webmin/letsencrypt-key.pem;
    ssl_protocols TLSv1.3;
    ssl_verify_client off;
    ssl_prefer_server_ciphers off;
    client_max_body_size 100G;

    location /.well-known/acme-challenge    { try_files $uri $uri/ =404; }
    location /.well-known/pki-validation    { try_files $uri $uri/ =404; }

    location / {
                allow 172.17.0.0/24;
                allow 192.168.255.0/24;
                deny all;
                proxy_pass http://127.0.0.11:4100;
               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;
                proxy_set_header X-Forwarded-Uri $request_uri;
                proxy_set_header User-Agent $http_user_agent;
                proxy_ssl_server_name on;
                proxy_set_header Connection "";
                proxy_set_header X-Forwarded-Host $host;
    }   

    error_page  404              /404.html;
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

}
  1. Configure letsencrypt (it is using a valid cert for every single domain.)

yes some things are redudant configured, they are left from tests. I will clean the unnecessary host entries as I already use wildcards.

Expected & Actual Behavior

The app should open, when opened is pressed in the dev center. The popup opens and shows can't connect to elements-6nvxf03mqbr-tx7qc.site.puter.localhost The actual index url works and has a valid certificate

Addition Information or Screenshots (if applicable) CleanShot 2024-10-04 at 08 16 59@2x

Deployment

Puter version (if accessible) 2.4.1

KernelDeimos commented 1 month ago

Set static_hosting_domain in your config to the desired domain for sites, for example site.puter.mydomain.de.

Patt92 commented 1 month ago

thanks, thia changed the url, but now it tries to access the app url with http, which fails

KernelDeimos commented 1 month ago

If you can upload your config that might help. I'm not sure what would cause it to do that, but is protocol set to anything in your config? Try setting protocol to https if it isn't already. If that still didn't work it's possible there's a bug, which I should be able to fix tomorrow (or later today depending on your timezone)

Patt92 commented 1 month ago

my config is in section 2. I only have redacted my domain and id's

KernelDeimos commented 2 weeks ago

Hi, apologies for the late reply on this. Did you ever resolve this? The only difference I can think of is that http_port is not set to 443. Are you able to configure it this way?