servus icon indicating copy to clipboard operation
servus copied to clipboard

servous does not find sites

Open sch1z00 opened this issue 1 year ago • 27 comments

I had already compiled from source on my Raspberry and created a site, so already using a structure with the directories "sites" (including the _config.toml) and "themes". Now I have compiled the new version but when I launch "servus" it finds a theme (default) but not the site in "sites":

Found theme: default
No config for theme: ./themes/default. Skipping!
0 themes loaded!
No themes found. Exiting!

sch1z00 avatar Nov 15 '24 16:11 sch1z00

Add some themes to the themes directory. Not all themes work yet. Try for example hyde. You can get it from here. Just clone this repo into themes/hyde. Then set your site's theme to "hyde".

ibz avatar Nov 15 '24 16:11 ibz

No themes found. Exiting!

The issue seems to be the lack of themes, not the site not being found.

ibz avatar Nov 15 '24 16:11 ibz

now, with the "hyde" theme, it works, it finds the site, but it doesn't see the "base_url" field in "_config.toml", and yet it is there

sch1z00 avatar Nov 15 '24 17:11 sch1z00

Could you show me your config and the error message?

ibz avatar Nov 15 '24 18:11 ibz

_config.toml

[site]
pubkey = "npub..."
base_url = "http://my.site.address"
title = "Schize"
tagline = "prova"
theme = "hyde"

Error

thread 'main' panicked at src/site.rs:443:39:
called `Result::unwrap()` on an `Err` value: Error { inner: Error { inner: TomlError { message: "missing field `base_url`", raw: Some("[site]\npubkey = \"npub...n\"\nbase_url = \"http://my.site.address\"\ntitle = \"Schize\"\ntagline = \"prova\"\ntheme = \"hyde\""), keys: [], span: Some(0..0) } } }

sch1z00 avatar Nov 15 '24 19:11 sch1z00

Try without [site]?

ibz avatar Nov 15 '24 20:11 ibz

yes, now it doesn't like [site], but I found out that tagline = "prova" didn't work either

now it works again, thank you

sch1z00 avatar Nov 15 '24 20:11 sch1z00

It's all still very much work in progress. Thanks for the patience!

ibz avatar Nov 15 '24 20:11 ibz

load everything (theme and site) but unfortunately now when I navigate http://my.site.address:4884 I have

tide::log::middleware <-- Request received
    method GET
    path /
tide::log::middleware Client error --> Response sent
    method GET
    path /
    status 404 - Not Found
    duration 344.645µs

http://my.site.address:4884/.admin works, although not perfectly

sch1z00 avatar Nov 15 '24 20:11 sch1z00

You need a page called "index" - basically what will render when you hit "/" from your browser. Go to the admin interface and create it. I agree this is confusing, I'll make it such that the index page is created automatically.

ibz avatar Nov 16 '24 11:11 ibz

I already have a page "index.md" that used to work in previous versions, now I also called it "index" but it doesn't work like that either.

sites/localhost
             |_ _config.toml
             |_ style.css
             |_ _content
                      |_ pages
                             |_ index.md
                             |_ posts.md
                      |_ posts
                             |_ 2024-06-27-prova3.md
             |_ _layouts
                      |_ base.html
                      |_ note.html
                      |_ page.html
                      |_ post.html
themes
    |_ hyde (cloned from github)

sch1z00 avatar Nov 16 '24 12:11 sch1z00

I pushed a change that renders "index" even if the page is not there. I think this makes sense, because the "index" page should always be there! So if you pull from GitHub and recompile, it should just work. But I still don't know why it does not work for you, as you have the "index" page there... Strange!

ibz avatar Nov 17 '24 21:11 ibz

http://my.site.address:4884/.admin works, although not perfectly

To be honest, the admin interface is pretty bad. I will probably just retire it. It was useful for me, but it is not something I want other people using, because it is bad, and I don't nave enough time to make it better. The goal is to have everything working over Nostr, so you should be able to use any Nostr client to manage your content... And there are Nostr clients a million times better than the admin interface I made (which is also a Nostr client BTW).

ibz avatar Nov 17 '24 21:11 ibz

Unfortunately, this doesn't work either.

called `Result::unwrap()` on an `Err` value: Error { kind: Msg("Failed to render 'index.html'"), source: Some(Error { kind: Msg("Variable `config.feed_filename` not found in context while rendering 'index.html'"), source: None }) }

The admin interface doesn't work either, it loads but doesn't do anything: it doesn't see my sites and even if I try to create a new one it doesn't "Save"

sch1z00 avatar Nov 18 '24 09:11 sch1z00

can you suggest me recent layouts?

sch1z00 avatar Nov 19 '24 10:11 sch1z00

Right, so I pushed another fix, please pull from GitHub and recompile.

Long story: some themes (including hyde which I had suggested) required this feed_filename to be present. And I had it in my config, but if you did not have it, it would break. So I made it default to atom.xml now, so it should work regardless.

Here is an example of a _config.toml that works:

base_url = "http://localhost:4884"
pubkey = "331a8d14e9f240de281ca744eee93c39aee385e20855e5033e064deb0674b429"
theme = "hyde"
title = ""

[extra]

ibz avatar Nov 25 '24 18:11 ibz

can you suggest me recent layouts?

Layouts come directly from the Zola themes, I did not modify them in any way. Not all themes work yet, it is mostly still a hit and miss, but my goal is to have them all work eventually.

ibz avatar Nov 25 '24 18:11 ibz

Right, so I pushed another fix, please pull from GitHub and recompile.

yes! it works!

thank you very much

sch1z00 avatar Nov 26 '24 10:11 sch1z00

The admin interface doesn't work either, it loads but doesn't do anything: it doesn't see my sites and even if I try to create a new one it doesn't "Save"

I assume it is because you are not using a Nostr extension in your browser. The admin interface uses Nostr for authentication. You need something like nos2x.

ibz avatar Nov 26 '24 10:11 ibz

... You need something like nos2x.

I have it

sch1z00 avatar Nov 26 '24 11:11 sch1z00

@ibz I'm running / testing Servus with a build binary (debug mode) and when I go to the ./admin path (https://servus.nostrver.se/.admin), I get the following response from the binary:

servus Nostr auth: NIP-98: Invalid 'u' tag: https://servus.nostrver.se/api/sites vs. http://servus.nostrver.se/api/sites.

I'm using the Alby extension in my browser and I see that the 'authorization' header is set when the request is made. Maybe the provided domain during the setup is not matching?

This is the current file / folder structure:

https://shares.sebastix.dev/k42sdzX5.png

and the content of the _config.toml:

pubkey = "npub19ysk0p0hkfq6d6ampav08mug9d2ymtar7cxv5en24pzuz2nrdfcqrae008"
base_url = "https://servus.nostrver.se"
title = ""
theme = "hyde"
[extra]

The u tag has this value when the auth event is signed: https://servus.nostrver.se/api/sites

Sebastix avatar Feb 17 '25 10:02 Sebastix

Invalid 'u' tag: https://servus.nostrver.se/api/sites vs. http://servus.nostrver.se/api/sites

It seems that Alby indeed is working as it should (the first value is the NIP-98 'u' tag - it includes https). The question is why the 2nd value is without https.

The provided domain during setup is simply prefilled in your _config.toml for convenience, but that also looks OK.

Are you sure you are trying to access the site using https and not http? Because that 2nd value in the log is the actual request that the server received.

ibz avatar Feb 19 '25 21:02 ibz

The URL is https://servus.nostrver.se/.admin where the request is made.

servus::site 1 sites loaded!
####################################
*** Your site: http://localhost:4884/ ***
*** The admin interface: http://localhost:4884/.admin/ ***
####################################
tide::server Server listening on http://0.0.0.0:4884

Is it maybe something I need to change in my nginx reverse proxy config?

upstream servus {
    server 127.0.0.1:4884;
}

server {
    server_name  servus.nostrver.se;
   
    location / {
        proxy_pass http://servus;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header  X-Frame-Options SAMEORIGIN;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        client_max_body_size 500M;
    }
    ...
}

Sebastix avatar Feb 21 '25 09:02 Sebastix

Ahh, I see, I never tested with nginx reverse proxy, because I designed it to work without. So it just works on a clean VPS. But I can see why that might be an issue if you have other stuff running and want to have an nginx in front.

I guess I'll test it in this scenario myself some day, but before that I have no idea...

Actually I think your nginx config might be fine and the bug may be on my side. I think what happens is - nginx connects to servus using http but it sets proxy_set_header X-Forwarded-Proto $scheme; which would let me know that the client connects to nginx using https, but I am not taking that header into account, so it looks like a mismatch...

I'll have a deeper look. Thank you for the report!

ibz avatar Feb 21 '25 20:02 ibz

I pushed a fix and released a new version that takes X-Forwarded-Proto into account. Curious if this fixed it for you.

ibz avatar Feb 22 '25 21:02 ibz

@ibz Auth seems to be working now (no errors), but a new error pops up (browser console) after sending the signed auth event:

alpinejs:5 Uncaught TypeError: Cannot read properties of undefined (reading 'domain')
    at getConfig (.admin:72:58)
    at [Alpine] await getSites(sites); site = sites[0]; await getConfig(site, themes); (eval at <anonymous> (https://unpkg.com/alpinejs:5:665), <anonymous>:3:78)

Sebastix avatar Feb 23 '25 13:02 Sebastix

Indeed, I also get that error in the browser console when accessing the admin interface when I have no sites. I pushed a fix. Do you want me to create a release as well, or are you compiling from source?

BTW, I think that you could have also just ignored that error and went on to create a site anyway, but thanks for reporting this!

ibz avatar Mar 04 '25 22:03 ibz