Both sides previous revisionPrevious revisionNext revision | Previous revision |
projets:fuz:spaceapi [2020-10-17 23:51] – grammar Lomanic | projets:fuz:spaceapi [2024-10-16 01:13] (current) – [Deployment] Lomanic |
---|
* Owner: [[:user:Lomanic]] | * Owner: [[:user:Lomanic]] |
* Participants: you? | * Participants: you? |
* Status: **functional beta** to be deployed on sonic | * Status: **online** |
* Project created on **Sat 17-10-20** by **[[:user:Lomanic]]** | * Project created on **Sat 17-10-20** by **[[:user:Lomanic]]** |
| |
===== Goals ===== | ===== Goals ===== |
* serve a [[https://spaceapi.io/|SpaceAPI]] endpoint at https://spaceapi.fuz.re | |
* set the opening status according to the [[presence button]] API at https://presence.fuz.re/api | * serve a [[https://spaceapi.io/|SpaceAPI]] endpoint at https://spaceapi.fuz.re (**done**) |
* add it to the [[https://spaceapi.io/directory/|directory]] so we can have nice opening stats at https://spaceapi.vanheusden.com/ and [[https://spaceapi.io/how-to-use/|other great goodies]] (we could finally have the opening state on the wiki: https://github.com/HackspaceJena/hackspace-status-dokuwiki-plugin, via [[https://www.binary-kitchen.de/wiki/doku.php?do=edit|Binary Kitchen wiki]]!) | * set the opening status according to the [[presence button]] API at https://presence.fuz.re/api (**done**) |
| * add it to the [[https://spaceapi.io/directory/|directory]] so we can have nice opening stats at https://spaceapi.vanheusden.com/ and [[https://spaceapi.io/how-to-use/|other great goodies]] (we could finally have the opening state on the wiki: https://github.com/HackspaceJena/hackspace-status-dokuwiki-plugin, via [[https://www.binary-kitchen.de/wiki/doku.php?do=edit|Binary Kitchen wiki]]!) (**done**) |
| |
===== Resources ===== | ===== Resources ===== |
| * Introduction to SpaceAPI on HaD https://hackaday.com/2021/06/18/do-you-spaceapi/ |
* https://spaceapi.io/ | * https://spaceapi.io/ |
* https://spaceapi.io/provide-an-endpoint/ | * https://spaceapi.io/provide-an-endpoint/ |
* https://github.com/SpaceApi/validator | * https://github.com/SpaceApi/validator |
| * https://metrics.spaceapi.community/ |
| |
Example of served JSON: | Example of served JSON: |
WantedBy=multi-user.target | WantedBy=multi-user.target |
EOF | EOF |
sudo systemctl enable spaceapi.service | sudo systemctl enable --now spaceapi.service |
sudo systemctl start spaceapi.service | |
curl localhost:3001 | curl localhost:3001 |
sudo mkdir -p /var/www/fuz.re/spaceapi/site | sudo mkdir -p /var/www/fuz.re/spaceapi/site |
sudo certbot certonly --webroot -w /var/www/fuz.re/spaceapi/site -d spaceapi.fuz.re --deploy-hook 'cat "$RENEWED_LINEAGE/privkey.pem $RENEWED_LINEAGE/cert.pem" > "$RENEWED_LINEAGE/combined.pem"' --post-hook '/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf && service lighttpd reload' | sudo certbot certonly --webroot -w /var/www/fuz.re/spaceapi/site -d spaceapi.fuz.re --deploy-hook '/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf && service lighttpd reload' |
</code> | </code> |
No need to mess with anything else, certbot is already called every ~12 hours as it was installed from Debian repos https://certbot.eff.org/docs/using.html#automated-renewals and lighttpd is reloaded after successful renewal. This config is persistent in ''/etc/letsencrypt/renewal/spaceapi.fuz.re.conf'' (automatically created by the previous certbot command). | No need to mess with anything else, certbot is already called every ~12 hours (see ''/etc/cron.d/certbot'') as it was installed from Debian repos https://certbot.eff.org/docs/using.html#automated-renewals and lighttpd is reloaded after a successful renewal. This config is persistent in ''/etc/letsencrypt/renewal/spaceapi.fuz.re.conf'' (automatically created by the previous certbot command), [[https://certbot.eff.org/docs/using.html#renewal-config-file|see its doc here]]. |
| |
| (To note: the certbot command was originally ''<nowiki>sudo certbot certonly --webroot -w /var/www/fuz.re/spaceapi/site -d spaceapi.fuz.re --deploy-hook 'cat "$RENEWED_LINEAGE/privkey.pem" "$RENEWED_LINEAGE/cert.pem" > "$RENEWED_LINEAGE/combined.pem"' --post-hook '/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf && service lighttpd reload'</nowiki>'' but combining certs is not useful anymore in lighttpd, see [[https://github.com/certbot/certbot/issues/94#issuecomment-658217459|certbot/certbot#94]]) |
| |
Corresponding lighttpd vhost config | Corresponding lighttpd vhost config |
<code> | <code> |
$HTTP["host"] == "spaceapi.fuz.re" { # added by Lomanic 20201017 | $HTTP["host"] == "spaceapi.fuz.re" { # added by Lomanic 20201017 |
$HTTP["scheme"] == "http" { | $HTTP["scheme"] == "http" { |
server.document-root = "/var/www/fuz.re/spaceapi/site" | server.document-root = "/var/www/fuz.re/spaceapi/site" |
$HTTP["url"] !~ "^/.well-known/acme-challenge/" { | $HTTP["url"] !~ "^/.well-known/acme-challenge/" { |
url.redirect = (".*" => "https://${url.authority}${url.path}${qsa}") | url.redirect = (".*" => "https://${url.authority}${url.path}${qsa}") |
} | } |
} | } |
| |
$SERVER["socket"] == ":443" { | $SERVER["socket"] == ":443" { |
ssl.engine = "enable" | ssl.engine = "enable" |
proxy.server = ( "" => (("host" => "127.0.0.1", "port" => 3001)) ) | proxy.server = ( "" => (("host" => "127.0.0.1", "port" => 3001)) ) |
ssl.ca-file = "/etc/letsencrypt/live/spaceapi.fuz.re/chain.pem" | ssl.pemfile = "/etc/letsencrypt/live/spaceapi.fuz.re/fullchain.pem" |
ssl.pemfile = "/etc/letsencrypt/live/spaceapi.fuz.re/combined.pem" | ssl.privkey = "/etc/letsencrypt/live/spaceapi.fuz.re/privkey.pem" |
} | } |
} | } |
==== 2020-10-17 (in the evening) ==== | ==== 2020-10-17 (in the evening) ==== |
| |
[[https://github.com/Lomanic/fuz-spaceapi|Pushed to GH]], made the app configurable via env variable, deployed on sonic by following what I (Lomanic) did during the [[evenements:log:20200606|Online Fuzturday #1]]. | [[https://github.com/Lomanic/fuz-spaceapi|Pushed to GH]], made the app fully configurable via env variable, deployed on sonic by following what I (Lomanic) did during the [[evenements:log:20200606|Online Fuzturday #1]]. Implemented certbot properly for this domain (see Deployment). |
| |
| ==== 2020-11-04 ==== |
| |
| Pull request opened https://github.com/SpaceApi/directory/pull/157 and merged! The hackerspace is now on [[https://api.spaceapi.io/]]! |
| |
| ==== 2022-09-27 ==== |
| |
| Redeployed on the new "octo" server, [[#deployment|following the previous documentation]] but with the following configuration in ''/etc/systemd/system/spaceapi.service'' |
| |
| <code> |
| Environment='SPACEAPI={"api":"0.14","api_compatibility":["14"],"space":"FUZ","logo":"https://wiki.fuz.re/lib/exe/fetch.php?media=wiki:logo.png","url":"https://fuz.re/","location":{"address":"57-59 Rue Étienne Marcel, 93100 Montreuil, FRANCE","lon":2.430790,"lat":48.858110},"contact":{"email":"","irc":"","ml":"fuz@fuz.re","twitter":"@fuz_re","matrix":"https://matrix.to/#/#fuz_general:matrix.fuz.re"},"issue_report_channels":["ml","twitter"],"state":{"icon":{"open":"https://presence.fuz.re/img","closed":"https://presence.fuz.re/img"},"message":"we are still moving in"},"projects":["https://wiki.fuz.re/doku.php?id=projets:fuz:start"]}' |
| </code> |
| |
| [[https://github.com/Lomanic/fuz-spaceapi/tree/spec0.14|With the following branch]], making our endpoint up to the 0.14 spec and not completely broken when there's no (like currently) presence API available |