Lemmy on Railway - Nginx proxy issue
lawansubba
TRIALOP

a year ago

Hi Guys,

I am trying to setup lemmy on railway, it basicaly contains 4 services
1) postgres
2) lemmy
3) lemmy-UI
4) proxy

all 4 services are operational on railway, then I need to use setup the reverse proxy as shown in the nginx conf file here

worker_processes 1;

error_log /dev/stderr debug;

pid /var/run/nginx.pid;

events {

worker_connections 1024;

}

http {

resolver [fd12::10] ipv6=on valid=1s;

upstream lemmy {

# this needs to map to the lemmy (server) docker service hostname

server "lemmy.railway.internal:8536";

}

upstream lemmyui {

# this needs to map to the lemmy-ui docker service hostname

server "lemmyui.railway.internal";

}

log_format verbose '$remote_addr - $remote_user [$time_local] '

'"$request" $status $body_bytes_sent '

'"$http_referer" "$http_user_agent" '

'"$request_body" "$bytes_sent"';

access_log /dev/stdout verbose;

server {

listen 80;

server_name _;

# Default proxy_pass URL

set $proxpass "http://lemmyui";

location / {

proxy_pass $proxpass;

# Proxy settings

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header Host $host;

proxy_set_header X-Nginx-Proxy true;

proxy_set_header X-Forwarded-Proto $scheme;

proxy_http_version 1.1;

}

}

}

But I am keep getting this error
2024/09/30 00:27:00 [error] 25#25: *5 upstream timed out (110: Operation timed out) while connecting to upstream, client: 100.64.0.4, server: _, request: "GET / HTTP/1.1", upstream: "http://[fd12:7673:5dd2::26:8cc2:3373]:80/", host: "proxy-test.up.railway.app"

The code on github is at https://github.com/lawansubba/lemmyPrompt/tree/main

1 Replies

a year ago

I would highly recommend scraping nginx, that valid 1s hack is not sustainable, you will at some point hit a stale ip and get an error.

Here is a very similar setup with caddy - https://github.com/vinfehring/plane-caddy-proxy/blob/main/Caddyfile

Also, a few things I need to point out -
- I see that lemmyui.railway.internal in that nginx config doesn't have a port, unless you know it's running on port 80 you need to specific a port.

- The private network is IPv6 only, so your services need to bind to IPv6 - https://docs.railway.app/guides/private-networking


Loading...