Skip to content

Self Hosting Issues Getting Started - 404 (Sign up not going through) #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
doronkatz opened this issue May 13, 2025 · 21 comments
Closed
Labels
answered Awaits end-user feedback

Comments

@doronkatz
Copy link

doronkatz commented May 13, 2025

Hi folks
Starting out new here. Trying to install on my mac mini via docker. My stack also includes caddy and tailscale, both of which I run using local standalone instead of docker versions. They work fine with my other apps.

When i go to sign up and enter my details it wont let me continue. It gives me a 404 error.

My .Caddyfile is:

...
## Rybbit Analytics
:443 {
    bind tailscale/analytics
    tls {
        get_certificate tailscale
    }
    tailscale_auth
    
    handle /api/* {
        reverse_proxy localhost:8101
    }
    
    handle {
        reverse_proxy localhost:8102
    }
}

My .env is:

# Variables configured by setup.sh
DOMAIN_NAME=analytics.tail7c7620.ts.net
BASE_URL=https://analytics.tail7c7620.ts.net
BETTER_AUTH_SECRET=<REDACT>
DISABLE_SIGNUP=false
USE_WEBSERVER=true
HOST_BACKEND_PORT="127.0.0.1:8101:3001"
HOST_CLIENT_PORT="127.0.0.1:8102:3002"

docker-compose not altered..

Logs are:

 docker logs client 
   ▲ Next.js 15.3.1
   - Local:        http://localhost:3002
   - Network:      http://0.0.0.0:3002

 ✓ Starting...
 ✓ Ready in 144ms

 docker logs backend
Running database migrations...

> [email protected] db:push
> drizzle-kit push --config=drizzle.config.ts --force

Reading config file '/app/drizzle.config.ts'
Using 'pg' driver for database querying
[⣷] Pulling schema from database...
[⣯] Pulling schema from database...
[⣟] Pulling schema from database...
[✓] Pulling schema from database...
[i] No changes detected
npm notice
npm notice New major version of npm available! 10.8.2 -> 11.3.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.3.0
npm notice To update run: npm install -g [email protected]
npm notice
Starting application...
[2025-05-13T04:52:14.987Z][WARN][@clickhouse/client][Config] "host" is deprecated. Use "url" instead.
2025-05-13T04:52:15.023Z WARN [Better Auth]: Social provider google is missing clientId or clientSecret
2025-05-13T04:52:15.024Z WARN [Better Auth]: Social provider github is missing clientId or clientSecret
GeoIP database loaded successfully
Starting server...
Loaded 0 sites into site config cache
Initializing cron jobs...
Cron jobs initialized successfully
2025-05-13 04:52:15.286+0000 - info - Server listening at http://127.0.0.1:3001
2025-05-13 04:52:15.286+0000 - info - Server listening at http://192.168.164.4:3001

Attached is UI error

Image

@Ultragian
Copy link

Same issue, only I don't use Caddy nor Tailscale, just accessing the Web-UI directly (doesn't work through NPM either).
There is nothing in the logs about it either.

@smileBeda
Copy link
Collaborator

Can you check if #135 solves your issue?
You need to rewrite /api to /

@doronkatz
Copy link
Author

I haven't tried it yet. Is there a branch or tag I can look at

@smileBeda
Copy link
Collaborator

No, you've to use a proxy and rewrite as of now.

@lunibo
Copy link

lunibo commented May 13, 2025

Rewriting /api to / does not seem to fix this problem:

Image

@smileBeda
Copy link
Collaborator

That's a different error, actually.
This one for me never happened

Fairly sure it's also related to some routing issue though, and should be somewhere in your setup, since I can't see that problem.

Could you maybe share the exact way you set this up? We can try to replicate and find solutions / fix

Thank you!

@doronkatz
Copy link
Author

Hmm. I've posted env and docker compose. I use caddy and so I posted caddy file. I also use Tailscale.

What can I post to help with understanding the setup ?

@smileBeda
Copy link
Collaborator

smileBeda commented May 13, 2025

Can you share your current caddy file please?
it should look somehow like this:

{$DOMAIN_NAME} {
    # Enable compression
    encode zstd gzip

    handle_path /api/* {
        // REWRITE RULE FOR /API to / HERE ONLY

        reverse_proxy backend:3001
    }


    # Proxy all other requests to the client service
    handle {
        reverse_proxy client:3002
    }

} 

I notice you map Docker to host port in your env. Could you also try to remove that, and instead map directly via caddy to the docker container?
This should work, since docker opens the port anyway on the host

For reference my NGINX backend block:

location /api/ {
    rewrite ^/api(/.*)$ $1 break;
    proxy_pass http://rybbit_backend:3001;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

(not sure abut the exact equivalent caddy syntax but I could imagine the trailing slashes are as well important in Caddy as they are in nginx). Not sure caddy can process the same type of regex, but it should help to understand where and how to rewrite)

@doronkatz
Copy link
Author

My Caddyfile is above in my post, the first thing.
Can you explain to me the map docker to host part? Where is that?

@smileBeda
Copy link
Collaborator

If the Caddy file you shared is still as in the first post, it is not rewriting /api to / as it should, due to #135
That is a issue that eventually will be fixed, but right now, it appears required
And, that rewrite should be only in the backend block, not in the front end block.

Can you explain to me the map docker to host part? Where is that?

In your .env, you have:

HOST_BACKEND_PORT="127.0.0.1:8101:3001"
HOST_CLIENT_PORT="127.0.0.1:8102:3002"

that is not how it is documented in the .env here: https://github.com/rybbit-io/rybbit/blob/master/.env.example

So, I am suspecting you did that to map host:docker ports, however, I can imagine this creating some conflicts this way.
Try to directly route the traffic in caddy as the caddy file shows: https://github.com/rybbit-io/rybbit/blob/master/Caddyfile
Of course, instead of container names, you can use HOSTIP:Port. This should work, since Docker exposes the port on the host in all cases, unless you do not expose ports at all in docker, however, since you said you did not alter docker-compose, it fairly certain does expose it.

Hope that makes sense!

@doronkatz
Copy link
Author

I cant figure it out :( Ill wait till the fix I suppose. I tried cleaning up Caddyfile according to the link but nothing. Happy to send mt docker compose again and see if there's anything there that I can do.

@smileBeda
Copy link
Collaborator

smileBeda commented May 14, 2025

Try this caddy file:

{$DOMAIN_NAME} {
    # Enable compression
    encode zstd gzip

    handle_path /api/* {
        # Strip /api from the path
        rewrite * /{path.*}

        reverse_proxy 127.0.0.1:3001
    }

    # Proxy all other requests to the client service
    handle {
        reverse_proxy 127.0.0.1:3002
    }
}

(this is assuming you run everything on the same machine - caddy, rybbit back and front end)

Then, change your .env to this:

# Variables configured by setup.sh
DOMAIN_NAME=analytics.tail7c7620.ts.net
BASE_URL=https://analytics.tail7c7620.ts.net
BETTER_AUTH_SECRET=<REDACT>
DISABLE_SIGNUP=false
USE_WEBSERVER=true
HOST_BACKEND_PORT="127.0.0.1:3001"
HOST_CLIENT_PORT="127.0.0.1:3002"

Then, restart the docker (I am not sure if you use pure docker compose or the setup.sh scripts, both offer ways to restart / rebuild the containers)

Let me know if that works!

@smileBeda smileBeda added the answered Awaits end-user feedback label May 14, 2025
@smileBeda smileBeda self-assigned this May 14, 2025
@doronkatz
Copy link
Author

Yep tried same thing no luck. Really odd. I didn't edit docker compose though not sure if it's needed

@smileBeda
Copy link
Collaborator

Sorry, I notice something else in your env:
USE_WEBSERVER=true

If you do that, I think you need to use their Caddy - that is, it appears to me you probably started off with the setup.sh script, as shown here? https://www.rybbit.io/docs/self-hosting#4-run-the-setup-script

That creates an .env file that will set the server to true, since it includes Caddy.
If you want to change that and user your own caddy, you have to use what they describe here https://www.rybbit.io/docs/self-hosting-advanced#using-your-own-web-server
Otherwise you basically get 2 caddies

What I suggest:

  1. Decide on which method you want to use (sounds like you want to NOT use their caddy, but your own, so use https://www.rybbit.io/docs/self-hosting-advanced#using-your-own-web-server)
  2. Make sure your caddy uses the proper config and rewrite
  3. Delete all env, and generated folders/etc and start anew.

Honestly, if you do not want to use their inbuilt server, I suggest https://www.rybbit.io/docs/self-hosting-advanced#docker-compose-setup-with-npm-without-exposing-ports - but that will require you to use the proxy in docker, so you can have it in the same network.

@smileBeda smileBeda added answered Awaits end-user feedback and removed answered Awaits end-user feedback labels May 14, 2025
@antoniolago
Copy link

A suggestion would be to add an environment variable to backend "PREFIX_PATH=/api" and add this to all routes (if not provided follow the current behavior) instead of needing to rewrite paths (which can get complicated depending on environment)

@github-actions github-actions bot removed the answered Awaits end-user feedback label May 14, 2025
@doronkatz
Copy link
Author

A suggestion would be to add an environment variable to backend "PREFIX_PATH=/api" and add this to all routes (if not provided follow the current behavior) instead of needing to rewrite paths (which can get complicated depending on environment)

Thanks how do I do that

@antoniolago
Copy link

A suggestion would be to add an environment variable to backend "PREFIX_PATH=/api" and add this to all routes (if not provided follow the current behavior) instead of needing to rewrite paths (which can get complicated depending on environment)

Thanks how do I do that

Actually that suggestion was meant for the maintainers as it would be necessary to implement into the backend's code itself, or maybe you can try if you're feeling like it via Pull Request, anyway sorry for the confusion lol

@smileBeda
Copy link
Collaborator

A suggestion would be to add an environment variable to backend "PREFIX_PATH=/api" and add this to all routes (if not provided follow the current behavior) instead of needing to rewrite paths (which can get complicated depending on environment)

Rest assured this is definitely a BUG, not something that is intended to be "this is how it has to be done"
The workaround here discussed simply avoids everyone waiting until any eventual fixes are implemented.

@doronkatz
Copy link
Author

doronkatz commented May 14, 2025 via email

@smileBeda
Copy link
Collaborator

In this case, @doronkatz - you should be able to follow #135 as it would be the main/same issue as this one.
Also note, there has just been a release to Caddyfile right now, that however will not work, see #250 :)

So don't copy that just yet :D

@smileBeda smileBeda added the answered Awaits end-user feedback label May 14, 2025
Copy link

Assuming the original need was handled, this will be automatically closed now.

@smileBeda smileBeda removed their assignment May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered Awaits end-user feedback
Projects
None yet
Development

No branches or pull requests

5 participants