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

a year 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

a year 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!


a year 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 11 months ago


a year ago

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


t-cc
PROOP

a year 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 /__/auth/handler?apiKey I got the root page, but running the caddfile locally I got the content from the firebase.


a year 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

a year 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!


a year 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

a year 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

a year ago

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


a year 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

a year ago

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

Thanks 🙌


a year 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 11 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...