revoltchat / self-hosted

Deploy Revolt using Docker.
904 stars 116 forks source link

bug: UNKOWNERROR : /api/auth/login 404 CODE #99

Closed anioji closed 5 days ago

anioji commented 6 days ago

What happened?

When i try register/login API-Server sending me 404 code

Error Screenshot from 2024-09-28 18-36-13

Client

/api/auth/session/login
Status 404
Version HTTP/2

API

api_1            |  INFO  rocket::server                                                   > POST /api/auth/session/login application/json:
api_1            |  ERROR _                                                                > No matching routes for POST /api/auth/session/login application/json.
api_1            |  WARN  _                                                                > No 404 catcher registered. Using Rocket default.
api_1            |  INFO  _                                                                > Response succeeded.

Dot ENV

# Hostname used for Caddy
# This should in most cases match REVOLT_APP_URL
HOSTNAME=https://revolt.my_domain.com

# URL to where the Revolt app is publicly accessible
REVOLT_APP_URL=https://revolt.my_domain.com

# URL to where the API is publicly accessible
REVOLT_PUBLIC_URL=https://revolt.dimitrash.pro/api
VITE_API_URL=https://revolt.my_domain.com/api

# URL to where the WebSocket server is publicly accessible
REVOLT_EXTERNAL_WS_URL=wss://revolt.my_domain.com/ws

# URL to where Autumn is publicly available
AUTUMN_PUBLIC_URL=https://revolt.my_domain.com/autumn

# URL to where January is publicly available
JANUARY_PUBLIC_URL=https://revolt.my_domain.com/january

Revolt.toml

app = "https://revolt.my_domain.com"
api = "https://revolt.my_domain.com/api"
events = "wss://revolt.my_domain.com/ws"
autumn = "https://revolt.my_domain.com/autumn"
january = "https://revolt.my_domain.com/january"

NGINX?!?!

Interdiction

I ignore Caddy - proxy because in my network with more self-hosted services entry point is nginx. Caddy send 301 when nginx proxing req on http If write https://... we get 502 code ... Nginx cant proxy to https services

Client -> Nginx -> Caddy -> 301 https://revolt.my_domain.com -> Nginx -> Client -> Nginx -> Caddy -> 301 https://revolt.my_domain.com ... Cycle

Settings

I opened ports in docker-compose and add to /etc/hosts local-address of my VM in my ingress server

server {
        listen 443;
        server_name revolt.my_domain.com;

        ssl_certificate /etc/nginx/certs/my_domain.com.crt;
        ssl_certificate_key /etc/nginx/certs/my_domain.com.key;

        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;

        location / {
                proxy_pass http://revolt.my_domain.com:83/;
        }
        location /api {
                proxy_pass http://revolt.my_domain.com:81/api;
        }

        location /autumn {
                proxy_pass http://revolt.my_domain.com:84/autumn;
        }

        location /january {
                proxy_pass http://revolt.dimitrash.pro:85/january;
        }

        location /ws {
                proxy_pass http://revolt.my_domain.com:82/ws;
                proxy_http_version 1.1;
                proxy_set_header Upgrade "websocket";
                proxy_set_header Connection "Upgrade";
        }
}
insertish commented 5 days ago

You need to strip the /api prefix when passing requests to the proxy. See https://github.com/revoltchat/self-hosted/blob/master/Caddyfile#L3.

(I don't know how nginx handles this but I can see in your logs that it is not stripping the path.)