Caddy proxy connection refused

alecapra96
HOBBY

10 months ago

I have a problem with the reverse proxy, I set the backend and frontend to listen on port 3000

I use railway reverse proxy variables
(2 photos)

but it gives me an error that rejects the connection
(3 photos)

Project ID : 5da60841-1f6c-4e52-a848-3130a3b8ab8e

0 Replies

alecapra96
HOBBY

10 months ago

In mi backend i use express:
```js
console.log("Server on");
const port = Number(process.env.PORT) || 3000;

return app.listen(port, "::", () => {
console.log(Server listening on [::]${port});
});```


alecapra96
HOBBY

10 months ago

1279183146675601700


alecapra96
HOBBY

10 months ago

in my frontend , i crete a domain
and its working

1279183538109026600


alecapra96
HOBBY

10 months ago

1279183939239673900


alecapra96
HOBBY

10 months ago

how can i fixed?


alecapra96
HOBBY

10 months ago

Fun fact: I had to use
in the packagejson in the backend
"build": "rm -rf ./dist && tsc || true",
and in the frontend
"build": "react-scripts build || true",

Why would the build stop if it had errors, even if my tsconfig was:

```"compilerOptions": {
    "noEmitOnError":` false,```

alecapra96
HOBBY

10 months ago

its a mono repo


10 months ago

When you are referencing something on the private network, you need the URL to be :port number so, for your example, your frontend_domain should be app-frontend.railway.internal:3000 and your caddy config should reference the variable


alecapra96
HOBBY

10 months ago

This caddy repo asks you for it separately, I tried the older one that was like that and it doesn't work


alecapra96
HOBBY

10 months ago

1279514953740587000


alecapra96
HOBBY

10 months ago

the caddy


alecapra96
HOBBY

10 months ago

this is the repo



10 months ago

yep the template does ask for the domain and port as separate variables.


alecapra96
HOBBY

10 months ago

in think i fixed


alecapra96
HOBBY

10 months ago

its deploying


alecapra96
HOBBY

10 months ago

i was a error with serve, not sure


alecapra96
HOBBY

10 months ago

in a few minutes i discover


10 months ago

the issue here is that your frontend is not listening on ipv6.


alecapra96
HOBBY

10 months ago

is the deploy is succes


alecapra96
HOBBY

10 months ago

yes


alecapra96
HOBBY

10 months ago

i use serve


10 months ago

you would want to be using caddy


10 months ago

  1. remove the build and start commands you have set in the service settings.

  2. - copy the nixpacks.toml and Caddyfile from this repo into yours.


Caddy proxy connection refused - Railway Help Station