Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
fc090a010c | |||
37ad9e62a2 | |||
e9edb55a47 | |||
962493f352 | |||
986a5cc1ee | |||
4622625570 | |||
88e9406963 | |||
320e94b40d |
6 changed files with 111 additions and 92 deletions
|
@ -31,7 +31,7 @@ mount '{{path}}' '{{mountpoint}}' -o bind,umask=100,uid={{uid}},gid={{gid}} || e
|
|||
local link = links[i]
|
||||
string = string .. t([[
|
||||
mkdir -p '{{dirname}}' || exit 1
|
||||
ln -s '{{target}}' '{{path}}' || exit 1
|
||||
ln -sf '{{target}}' '{{path}}' || exit 1
|
||||
]],
|
||||
{ dirname = utils.dirname(link.path),
|
||||
target = link.target, path = link.path }
|
||||
|
|
95
modules/nftables.lua
Normal file
95
modules/nftables.lua
Normal file
|
@ -0,0 +1,95 @@
|
|||
modules.nftables = {}
|
||||
add_packages({ "nftables" })
|
||||
add_file("/etc/nftables.nft", [[
|
||||
#!/usr/sbin/nft -f
|
||||
|
||||
flush ruleset
|
||||
|
||||
table inet filter {
|
||||
chain input {
|
||||
type filter hook input priority 0; policy drop;
|
||||
|
||||
iifname lo accept \
|
||||
comment "Accept any localhost traffic"
|
||||
|
||||
ct state { established, related } accept \
|
||||
comment "Accept traffic originated from us"
|
||||
|
||||
ct state invalid drop \
|
||||
comment "Drop invalid connections"
|
||||
|
||||
tcp dport 113 reject with icmpx type port-unreachable \
|
||||
comment "Reject AUTH to make it fail fast"
|
||||
|
||||
ip protocol icmp icmp type {
|
||||
echo-reply, # type 0
|
||||
destination-unreachable, # type 3
|
||||
echo-request, # type 8
|
||||
time-exceeded, # type 11
|
||||
parameter-problem, # type 12
|
||||
} accept \
|
||||
comment "Accept ICMP"
|
||||
|
||||
ip6 nexthdr icmpv6 icmpv6 type {
|
||||
destination-unreachable, # type 1
|
||||
packet-too-big, # type 2
|
||||
time-exceeded, # type 3
|
||||
parameter-problem, # type 4
|
||||
echo-request, # type 128
|
||||
echo-reply, # type 129
|
||||
} accept \
|
||||
comment "Accept basic IPv6 functionality"
|
||||
|
||||
ip6 nexthdr icmpv6 icmpv6 type {
|
||||
nd-router-solicit, # type 133
|
||||
nd-router-advert, # type 134
|
||||
nd-neighbor-solicit, # type 135
|
||||
nd-neighbor-advert, # type 136
|
||||
} ip6 hoplimit 255 accept \
|
||||
comment "Allow IPv6 SLAAC"
|
||||
|
||||
ip6 nexthdr icmpv6 icmpv6 type {
|
||||
mld-listener-query, # type 130
|
||||
mld-listener-report, # type 131
|
||||
mld-listener-reduction, # type 132
|
||||
mld2-listener-report, # type 143
|
||||
} ip6 saddr fe80::/10 accept \
|
||||
comment "Allow IPv6 multicast listener discovery on link-local"
|
||||
|
||||
ip6 saddr fe80::/10 udp sport 547 udp dport 546 accept \
|
||||
comment "Accept DHCPv6 replies from IPv6 link-local addresses"
|
||||
|
||||
tcp dport 80 counter accept \
|
||||
comment "Allow HTTP"
|
||||
}
|
||||
|
||||
chain forward {
|
||||
type filter hook forward priority 0; policy drop;
|
||||
}
|
||||
|
||||
chain output {
|
||||
type filter hook output priority 0; policy accept;
|
||||
}
|
||||
}
|
||||
|
||||
# The state of stateful objects saved on the nftables service stop.
|
||||
include "/var/lib/nftables/*.nft"
|
||||
|
||||
]])
|
||||
|
||||
modules.runit.add_service("nftables", [[#!/bin/sh
|
||||
if [ ! -r /etc/nftables.nft ]; then
|
||||
echo "No config, dropping everything"
|
||||
nft -f /dev/stdin <<-EOF
|
||||
flush ruleset
|
||||
table inet filter {
|
||||
chain input { type filter hook input priority 0; policy drop; }
|
||||
chain forward { type filter hook forward priority 0; policy drop; }
|
||||
chain output { type filter hook output priority 0; policy drop; }
|
||||
}
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
nft -f /etc/nftables.nft
|
||||
exec sleep infinity
|
||||
]])
|
|
@ -1,95 +1,9 @@
|
|||
modules.nginx = {
|
||||
domain_name = "pruebas.nulo.in",
|
||||
}
|
||||
|
||||
add_packages({ "nginx", "nginx-mod-http-brotli" })
|
||||
|
||||
modules.nginx = {}
|
||||
add_packages({ "nginx" })
|
||||
modules.fstab.add_tmpfs("/var/lib/nginx/tmp")
|
||||
|
||||
modules.data.add_data_dir("/data/nginx/logs", "/var/log/nginx", "nginx", "nginx")
|
||||
|
||||
modules.runit.add_service("nginx", [[#!/bin/sh
|
||||
exec 2>&1
|
||||
mkdir -p /run/nginx || exit 1
|
||||
exec nginx -g 'daemon off;'
|
||||
]])
|
||||
|
||||
add_file("/etc/nginx/nginx.conf", [[
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
pcre_jit on;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
|
||||
include /etc/nginx/modules/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
server_tokens off;
|
||||
|
||||
client_max_body_size 1024m;
|
||||
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
|
||||
ssl_session_tickets off;
|
||||
|
||||
ssl_dhparam /etc/ssl/nginx/dh2048.pem;
|
||||
|
||||
# https://ssl-config.mozilla.org/#server=nginx&version=1.22.0&config=intermediate&openssl=1.1.1p&guideline=5.6
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
|
||||
ssl_prefer_server_ciphers off;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_types application/atom+xml application/javascript application/json application/rss+xml
|
||||
application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype
|
||||
application/x-font-ttf application/x-javascript application/xhtml+xml application/xml
|
||||
font/eot font/opentype font/otf font/truetype image/svg+xml image/vnd.microsoft.icon
|
||||
image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml;
|
||||
|
||||
brotli on;
|
||||
brotli_static on;
|
||||
brotli_types application/atom+xml application/javascript application/json application/rss+xml
|
||||
application/vnd.ms-fontobject application/x-font-opentype application/x-font-truetype
|
||||
application/x-font-ttf application/x-javascript application/xhtml+xml application/xml
|
||||
font/eot font/opentype font/otf font/truetype image/svg+xml image/vnd.microsoft.icon
|
||||
image/x-icon image/x-win-bitmap text/css text/javascript text/plain text/xml;
|
||||
|
||||
# Helper variable for proxying websockets.
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
include /etc/nginx/http.d/*.conf;
|
||||
}
|
||||
|
||||
# TIP: Uncomment if you use stream module.
|
||||
#include /etc/nginx/stream.conf;
|
||||
]])
|
||||
|
||||
-- https://ssl-config.mozilla.org/ffdhe2048.txt
|
||||
add_file("/etc/ssl/nginx/dh2048.pem", [[-----BEGIN DH PARAMETERS-----
|
||||
MIIBCAKCAQEA//////////+t+FRYortKmq/cViAnPTzx2LnFg84tNpWp4TZBFGQz
|
||||
+8yTnc4kmz75fS/jY2MMddj2gbICrsRhetPfHtXV/WVhJDP1H18GbtCFY2VVPe0a
|
||||
87VXE15/V8k1mE8McODmi3fipona8+/och3xWKE2rec1MKzKT0g6eXq8CrGCsyT7
|
||||
YdEIqUuyyOP7uWrat2DX9GgdT0Kj3jlN9K5W7edjcrsZCwenyO4KbXCeAvzhzffi
|
||||
7MA0BM0oNC9hkXL+nOmFg/+OTxIy7vKBg8P+OxtMb61zO7X8vC7CIAXFjvGDfRaD
|
||||
ssbzSibBsu/6iGtCOGEoXJf//////////wIBAg==
|
||||
-----END DH PARAMETERS-----]])
|
||||
|
|
|
@ -2,6 +2,7 @@ mkdir("/etc/runit/runsvdir/default")
|
|||
add_symlink("/etc/runit/runsvdir/current", "/etc/runit/runsvdir/default")
|
||||
add_symlink("/etc/service", "/etc/runit/runsvdir/current")
|
||||
add_symlink("/etc/runit/stopit", "/run/runit/stopit")
|
||||
add_symlink("/etc/runit/reboot", "/run/runit/reboot")
|
||||
|
||||
local t = require "../utils/templater"
|
||||
local function add_executable(path, script)
|
||||
|
@ -361,9 +362,17 @@ if [ -z "$VIRTUALIZATION" ]; then
|
|||
fi
|
||||
]])
|
||||
|
||||
-- https://wiki.gentoo.org/wiki/Runit#Reboot_and_shutdown
|
||||
add_executable("/usr/local/sbin/rpoweroff", [[#!/bin/sh
|
||||
runit-init 0]])
|
||||
add_executable("/usr/local/sbin/rreboot", [[#!/bin/sh
|
||||
runit-init 6]])
|
||||
|
||||
add_packages({ "runit", "eudev" })
|
||||
modules.runit.add_service("getty-tty1", [[#!/bin/sh
|
||||
exec chpst -P getty 38400 tty1 linux]], false)
|
||||
modules.runit.add_service("getty-tty2", [[#!/bin/sh
|
||||
exec chpst -P getty 38400 tty2 linux]], false)
|
||||
modules.runit.add_service("getty-ttyS0", [[#!/bin/sh
|
||||
exec chpst -P getty 38400 ttyS0 linux]], false)
|
||||
|
||||
|
|
2
qemu.sh
2
qemu.sh
|
@ -15,4 +15,4 @@ qemu-system-x86_64 -enable-kvm -m 2048 \
|
|||
-net nic,model=virtio-net-pci \
|
||||
-net user,hostfwd=tcp:10.69.0.2:8080-:80 \
|
||||
-kernel boot/vmlinuz-virt -initrd boot/initramfs-virt \
|
||||
-append "root=/dev/sda rootfstype=squashfs modules=ext4 init=/sbin/runit-init $append" $qemuappend
|
||||
-append "root=/dev/sda rootfstype=squashfs modules=ext4 quiet init=/sbin/runit-init $append" $qemuappend
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
local utils = require("utils")
|
||||
local alpine = require("alpine")
|
||||
|
||||
local alpine_base_version = "3.16"
|
||||
local alpine_version = alpine_base_version..".0"
|
||||
local alpine_base_version = "3.17"
|
||||
local alpine_version = alpine_base_version..".1"
|
||||
local packages = {
|
||||
"alpine-baselayout",
|
||||
-- "alpine-conf",
|
||||
|
@ -49,6 +49,7 @@ module "hostname"
|
|||
module "dhcpcd"
|
||||
module "ntpsec"
|
||||
module "nginx"
|
||||
module "nftables"
|
||||
|
||||
print("=> Installing and upgrading packages...")
|
||||
utils.expect_nil(alpine.make_world(root, packages))
|
||||
|
|
Loading…
Reference in a new issue