Skip to content

Instantly share code, notes, and snippets.

@ibuildthecloud
Created April 3, 2024 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibuildthecloud/0d101b847425a5d19a5f1f252c473123 to your computer and use it in GitHub Desktop.
Save ibuildthecloud/0d101b847425a5d19a5f1f252c473123 to your computer and use it in GitHub Desktop.
tools: github.com/gptscript-ai/search/brave, sys.write, sys.http.html2text
1. First search the web for some good references on how to write Caddyfile according to the below instructions
2. Then write a the Caddyfile locally in the file Caddyfile
Instructions:
Create a web server that serves static files from the local directory /images at the URL /images. Those images
should have prompt content caching headers on them.
Also serve the local directory /css and /js at the URLs /css, /js respectively. Those static assets should be
served with gzip and brotli compression.
Finally /v1 should use FastCGI and proxy the request to a local PHP instance with the php pages being in /v1 locally
@ibuildthecloud
Copy link
Author

To run this you will need a Brave Search API key (they are free and quick to create). I got the following output. No clue if its correct

# Serve static files from /images with caching headers
@images {
  file path /images/*
}
header @images Cache-Control "max-age=5184000"

# Serve /css and /js with gzip and brotli compression
@static {
  file path /css/* /js/*
}
encode gzip brotli
header @static Cache-Control "max-age=5184000"

# FastCGI proxy for /v1 to local PHP instance
@v1 {
  path /v1/*
}
php_fastcgi @v1 unix//run/php/php-fpm.sock

# Serve all static files
file_server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment