Creating and maintaining a site with git
In this post, I will show you how to manage a simple static site with a git repository. I will mention but needless to say that you can apply this approach on any other server.
The root
If you're already running your own server (with nginx, apache, lighthttpd...) you may dismiss this step.
With Yunohost, if you don't want to get your hands too dirty with nginx configuration, we'll have to install a "sandbox", an empty app that will become the root of our site.
When I first installed Yunohost, this app was available from the interface but it seems that it is no longer the case. You will have to copy and paste this link in the "Install custom app" form at the bottom of the installation page.
https://github.com/YunoHost-Apps/multi_webapp_ynhGitea
Unless you already have a gitea server running, you will need to install one.
In order to create hooks on server side, you'll have to add a line to /opt/gitea/custom/conf/app.ini :
[security]
DISABLE_GIT_HOOKS = false
Remember to restart gitea
$ yunohost service restart gitea
Vous pourrez maintenant créer un post-receive hook sur votre dépot.
You'll then be able to create a post-receive hook on your repository.
#!/bin/sh
TARGET=/var/www/webapp_user/domain.tld_/
git --work-tree=$TARGET clean -fd
git --work-tree=$TARGET checkout --force
Finally, don't forget to give acces to gitea on the server:
$ chown gitea:gitea /var/www/webapp_user/domain.tld_/
Now everytime you'll run a git push on your client to the repository, git will take cade of updating your site.
Size issue
If you need big files (audio/video) or if you're pushing a lot of files at once, you might be limited by some default settings.
You can fix that by increasing git's postBuffer size:
$ git config --global http.postBuffer 400000000
This will raise it to 50MB (versus 1MB by default).
If you encounter the following error:
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413
You can increase the limit by editing /etc/nginx/conf.d/git.domain.tld.d/gitea.conf (on the server this time)
client_max_body_size 50M;
Then restart nginx:
$ yunohost service restart nginx
Autoindex / basic file server
Si vous voulez pouvoir vous consulter l'arborescence de votre serveur depuis n'importe quel navigateur, vous pouvez activer l'autoindex en modifiant le fichier /etc/nginx/conf.d/domain.tld.d/webapp_domain.tld_.conf
If you want to be able to browse the whole file system of your domain from any web browser, you can edit /etc/nginx/conf.d/domain.tld.d/webapp_domain.tld_.conf
location / {
autoindex on;
alias /path/to/root/ ;
}
Attention cependant, tout le monde pourra voir ce que vous avez sur votre serveur. En ce qui concerne les fichiers statiques (CSS, JS, police d'écriture...) utilisés sur les pages publiées, tout le monde peut déjà les voir, d'une manière contournée.
Be carfull though as everybody will be able to access it.
The only issue that comes to mind, regarding this visibility, would be if you were to store "hard-coded" passwords in text file, but it's a liabily that you should avoid in any case.
I use the autoindex to easily find font files or some javascript libraries.