2023-10-29 03:32:46 +00:00
|
|
|
#!/hint/bash -euE
|
2024-01-25 21:00:47 +00:00
|
|
|
# Copyright (C) 2023-2024 Umorpha Systems
|
2023-10-29 03:32:46 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
|
|
|
packages+=(nginx)
|
|
|
|
|
2023-11-04 07:12:33 +00:00
|
|
|
post_install+=(20:nginx:post_install) # must be before '30:certbot:post_install'
|
2023-10-29 03:32:46 +00:00
|
|
|
nginx:post_install() {
|
|
|
|
local arg_mountpoint=$1
|
|
|
|
|
2024-01-25 21:01:36 +00:00
|
|
|
install -Dm644 /dev/stdin "$arg_mountpoint/etc/nginx/nginx.conf" <<-'EOF'
|
2023-10-29 03:32:46 +00:00
|
|
|
# -*- mode: nginx; nginx-indent-level: 4; intent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
worker_processes 1;
|
|
|
|
|
2024-01-25 10:27:59 +00:00
|
|
|
error_log /var/log/nginx/main-error.log error;
|
2023-10-29 03:32:46 +00:00
|
|
|
|
|
|
|
events {
|
|
|
|
worker_connections 1024;
|
|
|
|
}
|
|
|
|
|
|
|
|
http {
|
2024-01-25 10:27:59 +00:00
|
|
|
error_log /var/log/nginx/main-error.http.log error;
|
|
|
|
access_log /var/log/nginx/main-access.http.log combined;
|
2023-10-29 03:32:46 +00:00
|
|
|
|
2024-01-25 10:28:46 +00:00
|
|
|
types_hash_max_size 4096;
|
2023-10-29 03:32:46 +00:00
|
|
|
include mime.types;
|
|
|
|
default_type application/octet-stream;
|
|
|
|
|
|
|
|
sendfile on;
|
|
|
|
keepalive_timeout 65;
|
|
|
|
|
|
|
|
gzip on;
|
|
|
|
|
2024-01-25 21:01:36 +00:00
|
|
|
root /var/empty;
|
|
|
|
access_log /var/log/nginx/main-access.http.$server_name.log combined;
|
2023-10-29 03:32:46 +00:00
|
|
|
|
|
|
|
include /etc/nginx/sites/*.conf;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
install -Dm644 /dev/stdin "$arg_mountpoint/etc/nginx/snippets/listen.conf" <<-'EOF'
|
|
|
|
# -*- mode: nginx -*-
|
|
|
|
listen 80;
|
|
|
|
listen [::]:80;
|
2024-01-25 21:01:36 +00:00
|
|
|
EOF
|
2023-10-29 03:32:46 +00:00
|
|
|
|
2024-01-25 21:01:36 +00:00
|
|
|
# The per-$server_name access log files are created by worker
|
|
|
|
# process' `http` user, not the master process' `root` user,
|
|
|
|
# so we need to give that user permission to create them.
|
|
|
|
install -Dm644 /dev/stdin "$arg_mountpoint/etc/tmpfiles.d/nginx.conf" <<-'EOF'
|
|
|
|
z /var/log/nginx 0775 - http
|
2023-10-29 03:32:46 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
systemctl --root="$arg_mountpoint" enable nginx.service
|
|
|
|
}
|