Unable to get caddy reverse proxy working on railway
t-cc
PROOP

6 months ago

I'm trying to configure a reverse proxy for firebase auth.

I added a caddyfile to the project root, but I can't get it to work. I tested that config file on my local machine and it works. According to the documentation:

Railpack uses a custom Caddyfile that is used to serve the static files. You can overwrite this file with your own Caddyfile at the root of your project.

Solved$10 Bounty

11 Replies

Railway
BOT

6 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


6 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 6 months ago


6 months ago

In what way is it not working? Any error messages? and can you share your Caddyfile here?


t-cc
PROOP

6 months ago

It's a vite SPA. This is the caddyfile:

# Caddyfile :{$PORT:8080} { handle /__/auth/* { reverse_proxy https://{$FIREBASE_ORIGINAL_AUTH_DOMAIN} { header_up Host {http.reverse_proxy.upstream.hostport} header_up X-Forwarded-Host {host} header_up X-Forwarded-Proto {scheme} } } handle { root * {$STATIC_PATH:/app/dist} try_files {path} /index.html file_server } }

If I open <my-railway-domain>/__/auth/handler?apiKey I got the root page, but running the caddfile locally I got the content from the firebase.


6 months ago

Just a few extra questions:

  1. your caddyfile is in your project root

  2. is it named Caddyfile (capitlization included)?

  3. do you have a dockerfile in your project root, this bypass building via Railpack which could mean the Caddyfile is not being used


t-cc
PROOP

6 months ago

Hi.
Te file is in the project root, I don't have dockerfile and the name seems ok.

It seems the system ignores my Caddyfile or something. I attached some screenshots about the build+upload process. Thanks!


6 months ago

Ooh, it looks like you're using Nixpacks, you may want to switch to Railpack within your service settings under the "Build" section


t-cc
PROOP

6 months ago

Ok. That's the problem.

There is something wrong with the UI. I have selected Railpack in the settings but don't work, so now I added a railway.json file and now it works!

/*railway.json*/
{ "build": { "builder": "RAILPACK" } }


Thanks. I think you have a bug in the UI.


t-cc
PROOP

6 months ago

Here a screenshot of my projector config. Before solved it and now.


6 months ago

Interesting, could you share the service id in question? You can find it in the URL above or in the command palette (cmd/ctrl + k), this will make it easier for the team to debug


t-cc
PROOP

6 months ago

This one: c781510c-3b00-4872-9d25-09cb574d7da2

Thanks raised_hands emoji


6 months ago

Awesome, thanks a ton, I've brought it up to the team. I'll also keep an eye out for similar issues from other people and raise accordingly, thank you for flagging.

All clear to mark this thread as solved then?


Status changed to Solved dev 6 months ago


Loading...