Host a website on the Pubnix

From Project Segfault Wiki
Revision as of 08:53, 15 March 2023 by Arya (talk | contribs) (its webapp-username.p.projectsegfau.lt)
A flowchart showing what happens when a user makes a request through your usersite. It's kind of a mess.

The basics

So you have a website and you want to host it. Great! Let's get started.

First of all, we use Caddy for web server because of its simplicity. You can install any web server you want using the Nix package manager, however, you will receive no support from us when you go that path. Maybe you have experience with nginx, which is cool, but we use Caddy here.

By default, we have a Caddy web server running with the configuration in ~/Caddyfile.

We also have a few QoL aliases such as rc (reload caddy), ft (format Caddyfile), vt (validate Caddyfile).

Your Caddy web server listens on `~/.webserver.sock`.

Any webserver you install needs to listen on `~/.webserver .sock`. If you don't, it will not be recognized by the master Caddy server.

The default Caddy configuration checks ~/public_html for static files. It also has PHP capability out of the box, so you can run a PHP website if you want to do that. (PHP 8.2)

Every user also gets access to *-username.p.projectsegfau.lt for hosting more applications.

For example, you can host your own web app on mywebapp-username.p.projectsegfau.lt, while your main website is on username.p.projectsegfau.lt.

To create a new configuration for a subdomain, just append the following to the Caddyfile.

http://webapp-username.p.projectsegfau.lt {
    bind unix/.webserver.sock
    reverse_proxy localhost:port
}