<!-- title: Hosting a website on the Pubnix description: published: true date: 2024-06-23T17:36:57.618Z tags: pubnix editor: ckeditor dateCreated: 2024-06-23T17:14:53.178Z --> <p>So you have a website and you want to host it. Great! Let's get started.</p> <p>First of all, we use Caddy for web server because of its simplicity. You can install any web server you want using the <a href="https://search.nixos.org/packages">Nix package manager</a>, 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.</p> <p>By default, we have a Caddy web server running with the configuration in ~/Caddyfile.</p> <p>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`.</p> <p>Any webserver you install needs to listen on `~/.webserver.sock`. If you don't, it will not be recognized by the master Caddy server.</p> <p>The default Caddy configuration checks ~/public_html for static files. It also has PHP and CGI capability out of the box, so you can run a PHP website if you want to do that. (PHP 8.2)</p> <p>Every user also gets access to *-username.p.projectsegfau.lt for hosting more applications.</p> <p>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.</p> <p>To create a new configuration for a subdomain, just append the following to the Caddyfile:</p> <pre><code class="language-plaintext">http://webapp-username.p.projectsegfau.lt { bind unix/.webserver.sock reverse_proxy localhost:port }</code></pre>