puter icon indicating copy to clipboard operation
puter copied to clipboard

invalid host header

Open rajivraghu opened this issue 1 year ago • 2 comments

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

rajivraghu avatar Oct 04 '24 19:10 rajivraghu

Same error for docker compose on linux

ajaymajgaonkar avatar Oct 05 '24 03:10 ajaymajgaonkar

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?

jelveh avatar Oct 05 '24 05:10 jelveh

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

dovholuknf avatar Oct 21 '24 11:10 dovholuknf

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?

logclinker avatar Oct 25 '24 23:10 logclinker

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

Byarain avatar Nov 04 '24 06:11 Byarain

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:

  • We need multiple domains because Puter apps run in iframes that communicate with our API. There is no secure way to accomplish this without multiple origins.
  • The above completely rules out connecting directly with the IP address.
  • The above two points mean any reverse proxy configuration is going to require careful configuration to avoid complications.

(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.)

KernelDeimos avatar Nov 06 '24 20:11 KernelDeimos

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

administrator@UBNT001:~$ hostname -f UBNT001

g0ldingkev avatar Nov 10 '24 21:11 g0ldingkev

@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.

flintstones-fred avatar Nov 11 '24 02:11 flintstones-fred

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.

Ciberbago avatar Nov 11 '24 17:11 Ciberbago

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

  • trying to connect to Puter without configuring a domain

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.

KernelDeimos avatar Nov 11 '24 18:11 KernelDeimos

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?

flintstones-fred avatar Nov 11 '24 19:11 flintstones-fred

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

hamoudydev avatar Nov 12 '24 07:11 hamoudydev

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.

andrew-Go1 avatar Nov 13 '24 17:11 andrew-Go1

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.

KernelDeimos avatar Nov 13 '24 23:11 KernelDeimos

All I did, I put puter.localhost:4100 and the error disappeared!

zurganyali avatar Dec 06 '24 15:12 zurganyali

I really can't get this to work on GitHub Code spaces (I get the invalid host header error). I didn't realize that this was such a recent post, so that's why I'm wondering if anyone has made it work on Code spaces?

Puter is too much for my Raspberry Pi 4 (and there too, I get the "Invalid host header" error, so I can't work on it.

I made a really cool contribution, but I can't test it, so i can't make a pull request :))

arthur-adriansens avatar Dec 07 '24 09:12 arthur-adriansens

I'm wondering if it would be possible to make Webpack launch without firewall, like in this issue https://github.com/webpack/webpack-cli/issues/2909

I tried changing the domain in volatile/config/config.json, like @andrew-Go1 suggested, but it sadly didn't work for me.

arthur-adriansens avatar Dec 07 '24 09:12 arthur-adriansens

Gm gm, mine worked, i made use of my local ip in both config file and host but when I visit the URL it just shows a blank screen config file

  • domain: "192.x.x.x.x"

host file:

  • 192.x.x.x.x. puter.local
  • 192.x.x.x.x api.puter.local

In the console I got this error

  • TypeError: Failed to execute 'fetch' on 'Window': Failed to parse URL from http://api.192.x.x.x.x:x/whoami

Image

KcPele avatar Jan 21 '25 23:01 KcPele

Same problem as @KcPele

meldalinn avatar Feb 25 '25 08:02 meldalinn

same problem. blueish screen running behind reverse proxy, using https and pub_port set to 443

fahadalisarwar1 avatar Feb 25 '25 11:02 fahadalisarwar1

Spent the last hour trying to get this to work and I'm pretty disappointed it has to be this difficult. Will not work for me either.

ItsNoted avatar Mar 01 '25 19:03 ItsNoted

Well, this is disappointing. I just put in a huge amount of effort to make this easier for people, but I guess it still wasn't good enough. 😕

This is the documentation for domain configuration: https://github.com/HeyPuter/puter/wiki/self_hosters-domains

If anyone still has issues please let me know.

KernelDeimos avatar Mar 01 '25 20:03 KernelDeimos

Please continue this thread on #1128 if the instructions above do not resolve the issue.

KernelDeimos avatar Mar 01 '25 20:03 KernelDeimos

@ItsNoted please let me know what issues you ran into - it should not take an hour to get Puter working, that's an awful experience

KernelDeimos avatar Mar 01 '25 20:03 KernelDeimos

I just discovered it today, and appreciate the effort. I just installed it with the docker compose and got the same issue. as it's a common issue among otherd, i suggest to use en ENV VARS to override the domain in config.json. Sounds possible ?

riv0manana avatar Mar 12 '25 17:03 riv0manana

Same as everyone, I discovered this project, wanted to try with docker compose and got Invalid Host header. After editing config.json I can access puter from puter.domain.com but I got this now :

Image

It's not really puter.domain.com in my exemple it's just for reference

r4lix avatar Apr 03 '25 00:04 r4lix