Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http page error #50

Open
Rabioli opened this issue Apr 13, 2022 · 7 comments
Open

Http page error #50

Rabioli opened this issue Apr 13, 2022 · 7 comments

Comments

@Rabioli
Copy link

Rabioli commented Apr 13, 2022

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
Copy link

rodti commented Apr 28, 2022

+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
Copy link

rodti commented Apr 29, 2022

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
Copy link

rodti commented Apr 29, 2022

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
Copy link

rodti commented Apr 29, 2022

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
Copy link

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

@MikeHuntington
Copy link

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
Copy link
Contributor

danorton commented Mar 4, 2023

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;
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants