Skip to content

Instantly share code, notes, and snippets.

@lighth7015
Last active March 10, 2023 13:58
Show Gist options
  • Save lighth7015/28504594d4b328fd7e58e9680a7beaf1 to your computer and use it in GitHub Desktop.
Save lighth7015/28504594d4b328fd7e58e9680a7beaf1 to your computer and use it in GitHub Desktop.

File layout

Filename Directory Description
Caddyfile /etc/caddy Main caddy file, largely unaltered.
laravel.conf /srv/http/caddy.conf.d Laravel configuration for Caddy sites
cors.conf /srv/http/caddy.conf.d CORS configuration for caddy sites
hpprx.devel.conf /srv/http/caddy.conf.d Configuration for internal site hpprx.devel
myrxportal.devel.conf /srv/http/caddy.conf.d Configuration for internal site myrxportal.devel and sso.myrxportal.devel
# The Caddyfile is an easy way to configure your Caddy web server.
# https://caddyserver.com/docs/caddyfile
#
# The configuration below serves a welcome page over HTTP on port 80. To use your
# own domain name (with automatic HTTPS), first ensure that your domain's A/AAAA
# DNS records are properly pointed to this machine's public IP, simply replace the line below with your
# domain name.
#
# https://caddyserver.com/docs/caddyfile/concepts#addresses
# Import additional caddy config files in /etc/caddy/conf.d/
import /etc/caddy/conf.d/* {
log http.log.access {
include http.log.access
output file /var/log/caddy/access.log
format transform "e[35m[{ts}]e[0m e[96me[1m{request>remote_ip}e[0m e[31m{request>headers>X-Forwarded-For}e[0m e[33m{request>method}e[0m e[92m{request>host}e[32m{request>uri}e[0m e[97m{status}e[0m e[90m{request>headers>User-Agent}e[0m e[34m{request>headers>Referer}e[0m" {
time_format "02/Jan/2006:15:04:05-0700"
}
}
#log {
# exclude http.log.access
# output file /var/log/caddy/caddy.log
# format json
#}
# Restrict the admin interface to a local unix file socket, whose directory is restricted
# to caddy:caddy. By default, the TCP socket allows arbitrary modification for any process
# and user that has access to the local interface. If admin over TCP is enabled, one should
# make sure implications are well understood.
# admin "unix//run/caddy/admin.socket"
acme_ca https://uscogls-p001/acme/directory/directory
acme_ca_root /etc/ca-certificates/extracted/HMNC_CA.pem
}
http:// {
# Set this path to your site's directory.
root * /usr/share/caddy
# Enable the static file server.
file_server
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
# Refer to the directive documentation for more options.
# https://caddyserver.com/docs/caddyfile/directives
}
import /srv/http/sites-enabled/*
import laravel-site hpprx.devel:443 /srv/http/domains/hpprx.devel HMNC_CA uscogls-p001
# main laravel snippet
(laravel-main) {
tls {
issuer acme {
dir https://{args.2}/acme/acme/directory
trusted_roots /etc/ca-certificates/extracted/{args.1}.pem
disable_tlsalpn_challenge
}
}
header server "Comprehensive Care Platform v.2"
header x-powered-by "RxPlatform v.1"
root * {args.0}/public
encode zstd gzip
php_fastcgi unix//run/php-fpm/php-fpm.sock
file_server
}
# Laravel snippet, wrapped/exposed as a TLD
(laravel-site) {
{args.0} {
import laravel-main {args.1} {args.2} {args.3}
}
}
# Laravel snippet, with CORS support
(laravel-cors) {
{args.0} {
import cors {args.2}
import laravel-main {args.2} {args.3} {args.4}
}
}
# myrxportal.devel
import laravel-cors myrxportal.devel:443 sso.myrxportal.devel /srv/http/domains/hpprx.devel HMNC_CA uscogls-p001
# sso.myrxportal.devel
import laravel-cors sso.myrxportal.devel:443 myrxportal.devel /srv/http/domains/hpprx.devel HMNC_CA uscogls-p001
@zuohuadong
Copy link

where is cors.conf ?

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