From afd4379eb9cf6609531c3d0dd69fc8f9352d656f Mon Sep 17 00:00:00 2001 From: Sean Howard Date: Tue, 19 May 2020 15:36:40 -0400 Subject: [PATCH] Added main file and created readme --- README.md | 14 +++++++++++++- httpd_conf.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100755 httpd_conf.sh diff --git a/README.md b/README.md index 44636de..efadecc 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ # httpd_config -Creates a quick and direct config for OpenBSD's httpd \ No newline at end of file +Creates a quick and direct config for OpenBSD's httpd + +Can be run via: +httpd_conf.sh [fqdn] [/path/to/root] [php] + +The php variable adds configs for passing to php-fpm.sock and sets the directory index to index.php + +The root must be relative to the chroot (typically /htdocs). + +I recently used this for: +httpd_conf.sh jackpoint.obscuritus.ca /htdocs/mediawiki php + +To generate a config for my mediawiki install for the Jackpoint Wiki I run for a shadowrun game diff --git a/httpd_conf.sh b/httpd_conf.sh new file mode 100755 index 0000000..5c40372 --- /dev/null +++ b/httpd_conf.sh @@ -0,0 +1,39 @@ +#/bin/sh +tld=$1 +dir=$2 +php=$3 + +echo "server "$tld" {" +echo ' listen on egress port 80' +echo ' location "/.well-known/acme-challenge/*" {' +echo ' root "/acme"' +echo ' request strip 2' +echo ' }' +echo ' location * {' +echo ' block return 302 "https://$HTTP_HOST$REQUEST_URI"' +echo ' }' +echo '}' +echo '' +echo "server "$tld" {" +echo ' listen on egress tls port 443' +echo ' tls {' +echo " certificate \"/etc/ssl/$tld.fullchain.pem\"" +echo " key \"/etc/ssl/private/$tld.key\"" +echo ' }' +echo ' location "/pub/*" {' +echo ' directory auto index' +echo ' }' +echo ' location "/.well-known/acme-challenge/*" {' +echo ' root "/acme"' +echo ' request strip 2' +echo ' }' +if [ -n "$php" ] +then +echo ' location "/*.php*" {' +echo ' fastcgi socket "/run/php-fpm.sock"' +echo ' }' +echo ' directory index "index.php"' +fi +echo " root \"$dir\"" +echo '}' +echo