Obsah

HomeRouter IV

Požadavky

Základ

Základní image

tftp 192.168.1.20 -m binary -c put openwrt-22.03.5-ath79-generic-ubnt_routerstation-pro-squashfs-factory.bin
Firmware Version: RSPRO.ar7100pro.v6.0.0-OpenWrt-r20134-5f15225c1e␍␊
'kernel' size, 0x00226e50 is not a multiple of block size, 0x00010000! Abort.␍␊
tftp 192.168.1.20 -m binary -c put openwrt-19.07.10-ath79-generic-ubnt_routerstation-pro-squashfs-factory.bin

Extroot

opkg install kmod-usb-storage mod-usb-core kmod-usb2 kmod-mmc block-mount

Příprava SD karty

pkg_hash_check_unresolved: cannot find dependency libuuid1 for e2fsprogs
pkg_hash_check_unresolved: cannot find dependency libext2fs2 for e2fsprogs
mkdir /tmp/newroot
mkdir /tmp/currroot
mount --bind / /tmp/currroot
mount /dev/sda /tmp/newroot/
tar -C /tmp/currroot -cvf - . | tar -C /tmp/newroot -xvf -
sync
config mount
	option target	/
	option device	/dev/sda
	option fstype	ext4
	option options	rw
	option enabled	1
	option enabled_fsck 0

Doinstalování balíčků na extroot

Doladění

Wireguard

opkg install luci-proto-wireguard // podpora v LUCI WebUI + závislosti
opkg install luci-app-wireguard // zobrazování stavu ve WebUI
config interface 'wg0'
        option proto 'wireguard'
        option private_key '*****'
        list addresses '10.0.0.2/24'

config wireguard_wg0
        option description 'peer1'
        option public_key '*****'
        option preshared_key '*****'
        list allowed_ips '10.0.0.1'
        list allowed_ips '172.17.17.0/24'
        option route_allowed_ips '1'
        option endpoint_host 'peer1.example.com'
        option persistent_keepalive '25'
        option endpoint_port '51820'

ACME

config cert 'wiki'
        option use_staging '0'
        option keylength '2048'
        option update_nginx '0'
        option update_haproxy '0'
        option enabled '1'
        list domains 'wiki.bari2.eu'
        option update_uhttpd '0'
        option validation_method 'webroot'
        option webroot '/www/acme'

HTTPS proxy

opkg install nginx-ssl luci-app-acme acme-dnsapi
vim /etc/config/nginx
config main global
        option uci_enable 'false'
cp /etc/nginx/uci.conf.template /etc/nginx/nginx.conf
server {

    listen 6666 ssl;
    server_name wiki.bari2.eu;

    ssl_certificate /etc/acme/wiki.bari2.eu/wiki.bari2.eu.cer;
    ssl_certificate_key /etc/acme/wiki.bari2.eu/wiki.bari2.eu.key;

    include conf.d/location-acme.inc;
    include conf.d/location-pi-fwd.inc;

}

server {

    listen 7777;
    server_name wiki.bari2.eu;

    include conf.d/location-acme.inc;
    include conf.d/location-https-fwd.inc;

}
location /.well-known/acme-challenge/ {
        default_type "text/plain";
        root /www/acme/;
}
location / {
 	return 301 https://$host$request_uri;
}
location / {
	proxy_pass https://192.168.0.5;
	proxy_set_header Host $host;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Forwarded-Proto $scheme;
}
server {
    listen 7777 ssl;
    server_name _;

    ssl_certificate conf.d/default.crt;
    ssl_certificate_key conf.d/default.key;

    # mohl bych sem dat acme include, aby to umelo overit jakoukoliv domenu
    # je to ale zbytecne, pokud ten ssl pak nepouzivam... tak jsem to zrusil
}

# pokud zadny server name nema exact mach (nebo regular/wildcard)
# vezme prvni unmatched server_name na tom portu
# takze zalezi na poradi .. ten default musi byt prvni
# hodnota "_" je jen nikdy nematchnuta hodnota, co nejkratsi :)

server {
    listen 8080;
    server_name _;

    # vse co neznam poslu na pi
    include conf.d/location-pi-http-fwd.inc;
}