Closed kirillrst closed 3 years ago
Yes, it's possible, but requires a slightly verbose configuration file, something like
server "host.com" {
...
location "/~foo/*" {
root "/home/foo/htdocs"
strip 1
}
# and so on for the other users
}
but for a large number of users it quickly becomes unmaintainable. I've been thinking how to simplify this use-case, but I haven't really come up with anything. I'm open for suggestion though :)
I've found this option in https://tildegit.org/solderpunk/molly-brown . It looks so nice in Lagrange. Without the option I see just main hostname.
I need this options for making public blog platform. It's so hard to edit config for each user.
Something like that?
server "host.com" {
usersroot "/home/foo/htdocs"
}
In Molly:
* DocBase: Base directory for Gemini content (default value /var/gemini/). Only world-readable files stored in or below this directory will be served by Molly Brown.
* HomeDocBase: Requests for paths beginning with ~/username/ will be looked up relative to DocBase/HomeDocBase/username/ (default value users). Note that Molly Brown does not look inside user's actual home directories like you may expect based on experience with other server software. Of course, you can symlink /var/gemini/users/gus/ to /home/gus/public_gemini/ if you want.
I like how MollyBrown handles that, how it doesn't look inside users' actual home directories but only inside a single directory. This was the biggest issue I had in trying to simplify this setup.
I'm going implement something like your example, a usersroot
option that points to a directory. Thanks! :)
On a second thought, this should already be possible with something like
server "example.com" {
location "/~*" {
root "/var/gemini/users"
}
}
Then example.com/~foo
, example.com/~bar/
, ... will be mapped to /var/gemini/users/~foo
, /var/gemini/users/~bar
etc
It's a bit tricky to create these ~user
directories because the shell expansion gets in the way, so you have to quote it, i.e. cd /var/gemini/users && mkdir '~foo'
. I'd like to implement something like httpd' request rewrite
in the future that will allow dropping the leading ~
.
I'll add something in the EXAMPLES section of the manpage.
I've pushed a commit in the master branch that relax the policy regarding symlinks. This diff should apply on top of the last version cleanly.
Just a final note: if you're going to build a public service, please use a tagged release instead of following the master branch. As explained in the README, I don't make any guarantees about the stability of the master branch, and in particular in this period I'm in the middle of a refactoring in the gmid internals; tagged releases on the other hand are stable and tested.
Unfortunately this config doesn't work. I can't start server with any config. Last Manjaro, gmid 1.7.2
[user@uhn GLOG]$ gmid -c /tmp/config
/tmp/config:6: invalid vhost definition: example.com
[user@uhn GLOG]$ cat /tmp/config
server "example.com" {
root "/example.com"
location "/~*" {
root "/var/gemini/users"
}
}
Could you give any working config?
Yeah, sorry, I trimmed out some details because I wanted to point out the idea.
Anyway, every server
block has a two mandatory fields cert
and key
. So, a working configuration is:
server "example.com" {
# these two must be a valid certificate and key
cert "/path/to/example.com.crt"
key "/path/to/example.com.key"
root "/var/gemini"
location "/~*" {
root "/var/gemini/users"
}
}
(btw, I agree that "invalid vhost definition" is not a useful error message. will improve that soon)
Thanks a lot. I apologize for my stupidity.
$ gmid -c GLOG/config
# output nothing
$ ps xuwwa | grep gmid
user 74104 0.0 0.0 7988 552 ? Ss 08:37 0:00 gmid -c GLOG/config
Cert was generated:
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout glog.key -out glog.crt -subj "/CN=glog.email" -addext "subjectAltName=DNS:glog.email,DNS:localhost,IP:127.0.0.1"
Config:
server "localhost" {
# these two must be a valid certificate and key
cert "/home/user/GLOG/glog.crt"
key "/home/user/GLOG/glog.key"
root "/home/user/GLOG"
location "/~*" {
root "/home/user/GLOG/users"
}
}
Journalctl:
июл 29 08:53:44 uhn gmid[74104]: open /home/user/GLOG/users for domain localhost
No listen port:
[user@uhn ~]$ ss -tulw | grep -c 1965
0
[user@uhn ~]$ ss -tulw | grep -c gmid
0
Do I need apply your patch?
Sorry. I will use Molly Brown. It works
/home/user/GLOG/users
is either:
users
) is a symlink, in which case you either need to use the master branch (not reccomended), apply the linked patch (reccommended) or wait for the next releaseAnyway, good luck with your project :)
Thanks a lot, Omar for yours time and attention. I will wait new release!
Is it possible? How can I make it?
I would like something like gemini://host.com/~user, where ~user is /rootdir/user/
Thanks in advance