💾 Archived View for farcaster.net › news › 2023-11-29.gmi captured on 2024-08-31 at 11:54:19. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-03-21)

-=-=-=-=-=-=-

Server change to gmid & FastCGI with PHP

I switched server from Agate to gmid, becaused I am planning on playing with dynamic content in Geminispace.

The current setup of this capsule consists of a Docker/Portainer/traefik server forwarding all traffic on port 1965 to the gmid server. The gmid is configured to forward some traffic based on a location to a php-fpm container.

gmid Gemini server

Portainer docker environment manager

PHP FastCGI Process Manager (FPM)

traefik proxy

Simple sample dynamic php app: Berlin local time display

If you find the information on this page useful, please set a back-link and/or let me know!

About & contact

Configuration

gmid server

gmid config file:

protocols "tlsv1.3"

server "*" {
	cert "/etc/cert/cert.pem"
	key  "/etc/cert/key.pem"
	root "/var/gemini/public"
	location "/app/*" {
		fastcgi tcp php
	}
	param SCRIPT_FILENAME = "/php/src/app.php"
}

portainer/traefik

Docker base images:

takaoni/gmid:latest

php:8.3-fpm

Stack configuration:

version: '3'

services:
  gmid:
    image: MY-BAKED-GMID-IMAGE
    restart: unless-stopped

    labels:
      - "traefik.enable=true"
      - "traefik.tcp.routers.gemini.entrypoints=gemini"
      - "traefik.tcp.routers.gemini.rule=HostSNI(`*`)"
      - "traefik.tcp.routers.gemini.service=gemini"
      - "traefik.tcp.routers.gemini.tls.passthrough=true"
      - "traefik.tcp.services.gemini.loadbalancer.server.port=1965"
    networks:
      - traefik-proxy
      - internal

  php:
    image: MY-BAKED-PHPFPM-IMAGE
    restart: unless-stopped
    networks:
      - internal

networks:
  internal:
  traefik-proxy:
    external: true

Sample PHP code

<?php

require_once __DIR__ . '/../vendor/autoload.php';

// Prepare Output for Gemini, make PHP not sending any headers ...
header_remove();
header("20 text/gemini");
# header_remove() is not enough! see:
# https://stackoverflow.com/questions/18326817/remove-content-type-header-in-apache
header('Content-Type: text/html');
header_remove('Content-Type');

$path = $_ENV["GEMINI_URL_PATH"];
$params = $_ENV["QUERY_STRING"];

Tags

#php

#gemini

1 Backlink