cloudflare tunnel and sveltekit
suryapratap-r
HOBBYOP

2 years ago

projectID: 171d055d-0855-415c-8f03-8b52fb322141

Hey, I am getting 502 bad gateway for my sveltekit application, I am using node adaptor.

I believe I followed all instructions as in https://railway.app/template/cf-tunnel

only place I think there is chance of not working out is IPV6 but still not sure as added --host :: for running

dockerfile```# Build stage

FROM node:lts-alpine AS builder

WORKDIR /app

COPY package*.json ./

RUN npm ci

COPY . .

ENV

ARG GOOGLE_CLIENT_ID

ENV VITE_GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}

... other env removed because of word limit of post

RUN npm run build

RUN npx drizzle-kit generate

Remove source files and keep only the built app and necessary runtime files

RUN rm -rf src tests scripts &&

npm prune --production

Production stage

FROM node:lts-alpine

A small line inside the image to show who made it

LABEL Developers="Suryapratap-R"

ENV NODE_ENV=production

RUN addgroup -S nodegroup && adduser -S nodeuser -G nodegroup

WORKDIR /app

COPY --from=builder /app/build ./build

COPY --from=builder /app/node_modules ./node_modules

COPY --from=builder /app/package.json ./package.json

Copy Drizzle migration files if needed

COPY --from=builder /app/migrations ./migrations

RUN chown -R nodeuser:nodegroup /app

USER nodeuser

Expose both development and production ports

EXPOSE 3000

HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3

CMD node -e "require('http').request('http://localhost:3000/healthz', (r) => {if (r.statusCode !== 200) throw new Error()})"

CMD ["sh", "-c", "sleep 3 && node build --host :: --port 3000"]```

my site is https://faqsense.com/ if thats relevant.

Closed

9 Replies

2 years ago

any reason you are using the tunnel to begin with?


suryapratap-r
HOBBYOP

2 years ago

to prevent againt ddos


2 years ago

why not just put your domain behind cloudflare


suryapratap-r
HOBBYOP

2 years ago

did not get it, my domain is already using cloudflare dns


suryapratap-r
HOBBYOP

2 years ago

I thought this is recommended setup, seen it on web dev cody's channel on youtube


suryapratap-r
HOBBYOP

2 years ago


2 years ago

massively overcomplex, simply add your custom domain to your service


suryapratap-r
HOBBYOP

2 years ago

please do let me know if this is not required / recommended way to do this.


2 years ago

its not required for your usecase


Welcome!

Sign in to your Railway account to join the conversation.

Loading...