HeyPuter / puter

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

invalid host header #785

Open rajivraghu opened 1 month ago

rajivraghu commented 1 month ago

Hello Dev, I opened the project in github codespace.. did npm install npm start

then i port forwaded
image

When i open the url that github codespace provides ... Ex:https://improved-disco-jgrv49xw4p3qjgj-4100.app.github.dev/ It says invalid host header

image

ajaymajgaonkar commented 1 month ago

Same error for docker compose on linux

jelveh commented 1 month ago

I suspect this is because you might be using a custom domain. Could you follow the instructions here and let me know if the issue persists?

dovholuknf commented 1 month ago

I'm running in docker compose, i have an /etc/puter/config.json. I ensured the domain is set:

docker exec -it browzerdc-puter-1 grep domain /etc/puter/config.json
    "domain": "puter.clint.demo.openziti.org",

I bounced the container via compose down / compose up yet still the header seems not to be respected. Is it possible to mount in the config to be sure it's the proper one being read/used?

I tried running interactively to see if there was any log on startup indicating the domain being used but there's no log. I also found and edited the 'protocol' but still no luck.

    "protocol": "https",

It's an interesting demo, I like using it if I can get by this

ahakobyan79 commented 1 month ago

I was trying to install Puter locally, kept getting this same error: Hardware: CPU: Intel i7 RAM: 16gb SSD: 128gb

NodeJs tried: 18, 21, 22, 23 (none worked) npm: 10.9

OS: Ubuntu Server 23, Zorin OS 17.2

I tried all options above, tried reinstalling multiple times, tried openning both with IP:4100 and with http://puter.localhost:4100

I get nothing at all with puter.localhost, and IP:4100 returns "Invalid Host header."

What am I missing here?

Byarain commented 3 weeks ago

I have also encountered the same issue and have tried it in different environments.

KernelDeimos commented 3 weeks ago

We're missing a piece of information to resolve this issue; I don't know how to reproduce this without configuring the domain incorrectly. If anybody can provide clear reproduction steps, that will help us resolve this issue. I expect this happens on environments that are difficult to support or is a common configuration mistake that we need to document more clearly.

Here's why this issue specifically impacts Puter, while you might not run into this issue with other projects:

(tangent: If browsers supported multiple "virtual" origins on a single origin, all of this would be a lot easier, and projects like Puter could be hosted securely without needing domain configuration at all. It seems crazy to me that this isn't a thing yet.)

g0ldingkev commented 2 weeks ago

i've tried this on ubuntu 22.04 with NO domain, just plain vanilla deployment

administrator@UBNT001:~$ hostname -f UBNT001

flintstones-fred commented 2 weeks ago

@KernelDeimos I am not the OP. But I would like to provide detailed instructions on how to reproduce the issue. I am not using an external domain. Everything is internal to my network. Here is the docker-compose file I am using -

Step 1: Create puter/data and puter/config directories:

mkdir -p /opt/puter/data /opt/puter/config
mkdir -p /opt/puter/config
chown -R 1000:1000 /opt/puter

Step 2: Prepare the docker-compose.

I am using Dockage to maintain my containers, but I don't think that should matter. Here is the docker-compose I am using:

services:
  puter:
    container_name: puter
    image: ghcr.io/heyputer/puter:latest
    pull_policy: always
    restart: unless-stopped
    ports:
      - 4100:4100
    environment:
      TZ: America/Chicago
      # CONFIG_PATH: /etc/puter
      PUID: 1000
      PGID: 1000
    volumes:
      - /opt/puter/config:/etc/puter
      - /opt/puter/data:/var/puter
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://puter.localhost:4100/test ||
        exit 1
      interval: 30s
      timeout: 3s
      retries: 3
      start_period: 30s
networks: {}

Step 3: Deploy

At this stage, just hit deploy in Dockage, which is equivalent to docker compose up -d

Step 4: Navigate to 192.168.1.228:4100

Note that 192.168.1.228 is my local IP. At this point, I am presented with Invalid Host header. as the only text on the webpage.

Ciberbago commented 2 weeks ago

I have the same problem, just copied the docker compose file, docker compose up -d, I open the IP with the correct port and it presents the message "Invalid host header". It's the simplest setup so I'm lost.

KernelDeimos commented 2 weeks ago

Please correct me if I'm wrong, but I believe the last three replies all have this in common:

For security reasons, because of how CORS works, Puter requires multiple origins. This also rules out connecting directly with an IP address. It sucks, and there's very little we can do about it because we're at the mercy of how web browsers work.

flintstones-fred commented 2 weeks ago

Thanks for explaining this. I am not going to pretend I understood everything. However, if I spin up a new container in Proxmox, and then follow the exact directions for docker compose, this should work?

hamoudydev commented 2 weeks ago

Thanks for explaining this. I am not going to pretend I understood everything. However, if I spin up a new container in Proxmox, and then follow the exact directions for docker compose, this should work?

localhost:4100 will not work. you'll need to have it behind a reverse proxy. change the domain in config.json from puter.localhost to puter.yourdomain.com

andrew-Go1 commented 2 weeks ago

Same error for docker compose on linux

I had the same problem and take a lot of tries fixing it. All works fine just after I change volatile/config/config.json with my domain, same as I make in /etc/hosts on my other machine.

KernelDeimos commented 2 weeks ago

I discovered a service called nip.io. For anyone wishing for this to work without setting up a domain, you can use this service because it allows for the api. subdomain to be prepended to the "ip address" (the nip.io domain that represents the IP address).

For anyone wishing to get an existing domain working, I believe what @andrew-Go1 said is the solution for most cases. I'm open to suggestions on how we can make this simpler to configure or easier to understand, since this seems to be a very common blocker for people.