yukimochi / Activity-Relay

Yet another powerful customizable ActivityPub relay server written in Go.
https://relay.toot.yukimochi.jp/
GNU Affero General Public License v3.0
281 stars 39 forks source link

Http page error #50

Open Rabioli opened 2 years ago

Rabioli commented 2 years ago

The relay seems to be working, the logs and the test I ran in my instance seem to support that, however I don't see any page that shows who is in the relay and furthermore where I attempt to connect to the listening port it just returns a plain "404 page not found", it doesn't respect the icon or anything "cosmetic" I set up. Is that even included?

For what I saw in your page I assumed it was going to look like that roughly, is there no http server that shows the instances connected to the relay?

rodti commented 2 years ago

+1 for this. Is it possible to configure content for the root / of the site served by ActivityRelay, or will it always be stuck showing a 404 error? It would be good to display even simple information at the root.

rodti commented 2 years ago

A good example of this is Yukimochi's own relay. The URL https://relay.toot.yukimochi.jp/ serves an information page, but the endpoints are at https://relay.toot.yukimochi.jp/inbox and https://relay.toot.yukimochi.jp/actor. Is the information page being served by the relay software, or using some sort of redirect in the web server?

rodti commented 2 years ago

I thought it might be possible to have specific proxy_pass clauses for /actor and /inbox which pass through to the relay, and a separate one for / serving static content. I might have malformed the nginx directives here, but / is still intercepted by the relay and shows a '404 not found' when serving an index.html file. Interestingly, if no file is there I get a standard nginx '403 Forbidden' page.

location = / {
root /var/www/html;
}

location = /inbox {
proxy_pass http://127.0.0.1:8080;
proxy_pass_request_headers on;
proxy_set_header Host $http_host;
}

location = /actor {
proxy_pass http://127.0.0.1:8080;
proxy_pass_request_headers on;
proxy_set_header Host $http_host;
}
rodti commented 2 years ago

Fixed! If I use the following then I can serve an index.html file from the /var/lib/relay folder (where my config.yml lives), with the endpoints also functioning correctly.

location = / {
root /var/lib/relay;
try_files $uri $uri/index.html =404;
}

location = /inbox {
proxy_pass http://127.0.0.1:8080;
proxy_pass_request_headers on;
proxy_set_header Host $http_host;
}

location = /actor {
proxy_pass http://127.0.0.1:8080;
proxy_pass_request_headers on;
proxy_set_header Host $http_host;
}
MikeHuntington commented 1 year ago

Hi @rodti whenever I use this I get a 502 error during the proxy pass. Did you see that happening on your end?

MikeHuntington commented 1 year ago

For anyone else using the docker version of this relay, you have to do a bit more setup in the docker-compose file and in the nginx conf.

Here's what my updated docker-compose looks like: as you can see I gave my server container the name "relay" this will be used later in the nginx file

version: "2.3"
services:
  redis:
    restart: always
    image: redis:alpine
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
    volumes:
      - "./redisdata:/data"

  worker:
    container_name: worker
    build: .
    image: yukimochi/activity-relay
    working_dir: /var/lib/relay
    restart: always
    init: true
    command: relay worker
    volumes:
      - "./actor.pem:/var/lib/relay/actor.pem"
      - "./config.yml:/var/lib/relay/config.yml"
    depends_on:
      - redis

  server:
    container_name: relay
    build: .
    image: yukimochi/activity-relay
    working_dir: /var/lib/relay
    restart: always
    init: true
    ports:
      - "8080:8080"
    command: relay server
    volumes:
      - "./actor.pem:/var/lib/relay/actor.pem"
      - "./config.yml:/var/lib/relay/config.yml"
    depends_on:
      - redis

For the nginx config we need to set and upstream for our proxy config to listen to that relay container's port 8080

upstream relay {
    server relay:8080;
  }
  server {
    server_name relay.example.com;

    location / {
      root /var/lib/relay;
      try_files $uri $uri/index.html =404;
    }

    location /inbox {
      rewrite ^/inbox(.*) /$1 break;
      proxy_pass http://relay/;
      proxy_pass_request_headers on;
      proxy_set_header Host $http_host;
    }

    location /actor {
      rewrite ^/inbox(.*) /$1 break;
      proxy_pass http://relay/;
      proxy_pass_request_headers on;
      proxy_set_header Host $http_host;
    }

  }
danorton commented 1 year ago

I have this in my nginx config to serve index.html if only the root path is specified:

  location ~ ^/$ {
    try_files $uri $uri/index.html =404;
  }

  location / {
    try_files $uri @proxy;
  }