3.1 KiB
3.1 KiB
Peninsula - Backend
The backend provides all necessary API endpoints to guarantee that the frontend does not require any server-side dynamic content generation. This should ensure that hosting the frontend is much cheaper than hosting the backend, likely requiring far less servers to handle. This backend is based on the lightweight CodeIgniter framework to simplify how much work is required for the implementation.
Requirements
We require some PHP modules for proper operation:
And depending on your Database of choice, one of:
Installation
Released Build
- Download the backend package from the provided release packages.
- Extract it on your server.
- Perform the Configuration step.
- Set the web root to be the
public/directory. - Set up rewrites or try_files to rewrite any non-existing request to
/index.php. - Enjoy.
Local Build
- Make a fresh clone of this repository, or run
git clean -fqX. - Run
composer install --no-dev. - Copy the contents of this directory to the machine that is supposed to host the backend.
- Set up your webserver to have a virtual host with a root directory pointing at
public/. - Ensure that all requests that don't match an exact file are forwarded to
index.php. - Enjoy.
Example Server Configurations
These examples are provided without warranty or guarantee of functionality. They're references to look at and configure your own server with.
nginx
server {
# The hostname under which we can find this server.
server_name "backend.peninsula.example.com";
# Listen for both HTTP and HTTPS.
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
# Enable HTTP2 and QUIC (HTTP3).
http2 on;
quic_gso on;
# Set up the necessary SSL certificates for HTTPS.
ssl_certificate "/etc/certs/snakeoil.pub";
ssl_certificate "/etc/certs/snakeoil.priv";
# Set the root to the proper directory.
root "/var/www/peninsula/backend/public/";
# Try a few paths before handing it off to the framework.
try_files $uri $uri/ /index.php?$request_uri;
# Disallow access to all files starting with a '.', except for localhost.
location ~ /\. {
allow 127.0.0.1;
deny all;
}
# Turn off logging for common files.
location = /favicon.ico {
access_log off;
log_not_found off;
error_log off;
}
location = /robots.txt {
access_log off;
log_not_found off;
error_log off;
}
# Handle PHP Files
location ~* [^/]\.php(|/.*)(|\?.*)$ {
include "fastcgi.conf";
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(|/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
# Always try the PHP files
try_files $fastcgi_script_name?$request_uri $fastcgi_script_name =404;
}
}