sheodox / alexandrite

A beautiful and convenient desktop-first alternate web UI for Lemmy.
https://alexandrite.app
GNU Affero General Public License v3.0
233 stars 21 forks source link

Is running Alexandrite on the base domain suported? #53

Closed ethernic closed 1 year ago

ethernic commented 1 year ago

I've been messing around with a self hosted Lemmy instance at ctrlaltelite.xyz. Right now I have Alexandrite site up on the base domain and currently have Lemmy-ui on m.ctrlaltelite.xyz. I also have a.ctrlaltelite.xyz pointing to Alexandrite.

The functionality on the base domain seems to be working but I'm missing some glyphs on the page in Firefox only (Brave/Edge work fine.) The glyphs are not missing on a.ctrlaltelite.xyz.

Missing glyphs: alexandrite

The relevant portion of my docker compose:

  alexandrite:
    image: ghcr.io/sheodox/alexandrite:latest
    hostname: alexandrite
    container_name: alexandrite
    restart: unless-stopped
    depends_on:
      - lemmy-app
    environment:
      - ALEXANDRITE_DEFAULT_INSTANCE=${ALEXANDRITE_DEFAULT_INSTANCE}
      - ALEXANDRITE_WELCOME_LEMMY_HELP=${ALEXANDRITE_WELCOME_LEMMY_HELP}
      - ALEXANDRITE_WELCOME_INSTANCE_HELP=${ALEXANDRITE_WELCOME_INSTANCE_HELP}
      - ALEXANDRITE_FORCE_INSTANCE=${ALEXANDRITE_FORCE_INSTANCE}
    networks:
      - backend
      - frontend

.env:

ALEXANDRITE_DEFAULT_INSTANCE=ctrlaltelite.xyz
ALEXANDRITE_WELCOME_LEMMY_HELP=false
ALEXANDRITE_WELCOME_INSTANCE_HELP=false
ALEXANDRITE_FORCE_INSTANCE=ctrlaltelite.xyz

My caddy config:

*.ctrlaltelite.xyz, ctrlaltelite.xyz {
    import init_external "ctrlaltelite.xyz"
    encode gzip zstd
    import caddy-common
    reverse_proxy alexandrite:3000

    @a host a.ctrlaltelite.xyz
    import logger "a.ctrlaltelite.xyz"
    handle @a {
        reverse_proxy alexandrite:3000
    }

    @lemmy {
        path /api/*
        path /pictrs/*
        path /feeds/*
        path /nodeinfo/*
        path /.well-known/*
    }

    @lemmy-hdr {
        header Accept application/*
    }

    @lemmy-post {
        method POST
    }

    handle @lemmy-hdr {
        reverse_proxy lemmy-app:8536
    }

    handle @lemmy {
        reverse_proxy lemmy-app:8536
    }

    handle @lemmy-post {
        reverse_proxy lemmy-app:8536
    }

    @m host m.ctrlaltelite.xyz
    import logger "m.ctrlaltelite.xyz"
    import caddy-common
    handle @m {
        reverse_proxy lemmy-ui:1234
    }

    @status host status.ctrlaltelite.xyz
    handle @status {
        reverse_proxy iamfoo:2001 {
        header_up Host {http.reverse_proxy.upstream.hostport}
      }
      header {
        -Server
      }
    }
}
sheodox commented 1 year ago

It should run on whatever domain you put it (the official instance runs on the base domain). My guess would be something to do with the proxy, but I'm also unsure.

It's 404ing trying to load some fonts (fontawesome, ttf and woff2). I'm not familiar with Caddy but are there any settings somewhere for which types of files it's allowed to serve?

ethernic commented 1 year ago

There's nothing I can find that's restricting it on Caddy's end. If it were I'd also expect it to not work on a.ctrlaltelite.xyz. I'm even more confused since this is specifically a problem on my base domain with Firefox. Base domain in Brave works as expected and the a. subdomain works in Firefox.

The only difference I can see between base domain and sub domain in Firefox is when things work on the sub domain the request is HTTP/2 but when it fails on the base domain in Firefox the 404s are HTTP/1.1. I forced this to HTTP/2 and I'm still getting the 404s.

ethernic commented 1 year ago

I got this working with help from the caddy team. It turned out to be an issue with the header Accept application/* matcher sending Firefox specific requests to my lemmy-app container instead of my Alexandrite one. Removing this matcher fixed the issue.

I'll submit a PR to the official Lemmy documentation to improve their suggested Caddy config since that was (partly) where I went wrong.