Hi misc,

I try to setup relayd(8) as load balancer for two Python3.6 based aiohttp
web-servers on -stable. Right now I´m just playing around to get into it
so everything runs inside a VirtualBox Instance.
For every aiohttp instance I created one vether(4) and assigned 10.0.0.x/24
to it and start each aiohttp-server manually with it´s own host-IP on port
8080.
Mostly I followed the examples within "Relayd and Httpd Mastery"
by Marcus W. Lucas. There is no problem with this aiohttp-servers and
vether(4)
because relayd(8) successfully does the health check with
'check http "/" code 200'
Right now the main problem is that relayd(8) dosen´t listen (on 0.0.0.0:80),
as httpd does for example. What I´m missing here?

Thanks for your support!

Here are my configs and some further info that should be helpful:

$ doas cat /etc/sysctl.conf
net.inet.ip.forwarding=1

----

$ doas ifconfig vether
vether0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        lladdr fe:e1:ba:d0:f5:6f
        index 5 priority 0 llprio 3
        groups: vether
        media: Ethernet autoselect
        status: active
        inet 10.0.0.1 netmask 0xffffff00 broadcast 10.0.0.255
vether1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        lladdr fe:e1:ba:d1:22:b2
        index 6 priority 0 llprio 3
        groups: vether
        media: Ethernet autoselect
        status: active
        inet 10.0.0.2 netmask 0xffffff00 broadcast 10.0.0.255

---

[start two aiohttp servers]
# python3.6 -m aiohttp.web -H 10.0.0.1 -P 8080 main:init &

[1] 53857

# python3.6 -m aiohttp.web -H 10.0.0.2 -P 8080 main:init &
[2] 39992


$ curl -I 10.0.0.1:8080
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 14
Date: Tue, 20 Jun 2017 21:03:41 GMT
Server: Python/3.6 aiohttp/2.1.0

$ curl -I 10.0.0.2:8080
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 14
Date: Tue, 20 Jun 2017 21:03:50 GMT
Server: Python/3.6 aiohttp/2.1.0

$ doas cat /etc/pf.conf:

set block-policy return
set loginterface egress
set skip on lo
match in all scrub (no-df random-id max-mss 1440)
anchor "relayd/*"
match out on egress inet from !(egress:network) to any nat-to (egress:0)
block all
pass out quick inet

$ doas cat /etc/relayd.conf
ext_if="0.0.0.0"
aio1="10.0.0.1"
aio2="10.0.0.2"
table <upstream> { $aio1, $aio2 }
# interval 10
# timeout 1000
# prefork 1

redirect www {
        listen on $ext_if tcp port 80
        forward to <upstream> port 8080 check http "/" code 200
}

$ doas relayd -n
configuration OK

$ doas relayd -dvv
socket_rlimit: max open files 1024
socket_rlimit: max open files 1024
pfe: filter init done
startup
socket_rlimit: max open files 1024
socket_rlimit: max open files 1024
relayd_tls_ticket_rekey: rekeying tickets
init_tables: created 1 tables
hce_notify_done: 10.0.0.1 (http code ok)
host 10.0.0.1, check http code (17ms,http code ok), state unknown -> up,
availability 100.00%
hce_notify_done: 10.0.0.2 (http code ok)
host 10.0.0.2, check http code (21ms,http code ok), state unknown -> up,
availability 100.00%
pfe_dispatch_hce: state 1 for host 1 10.0.0.1
pfe_dispatch_hce: state 1 for host 2 10.0.0.2
table www: 2 added, 0 deleted, 0 changed, 0 killed
pfe_sync: enabling ruleset
sync_ruleset: rule added to anchor "relayd/www"
hce_notify_done: 10.0.0.1 (http code ok)
hce_notify_done: 10.0.0.2 (http code ok)
[...]

---

$ netstat -na -f inet | grep LISTEN
tcp          0      0  127.0.0.1.25            *.*                    LISTEN
tcp          0      0  *.22                         *.*
 LISTEN
tcp          0      0  10.0.0.2.8080          *.*                    LISTEN
tcp          0      0  10.0.0.1.8080          *.*                    LISTEN

---

$ doas dmesg
OpenBSD 6.1 (GENERIC) #9: Mon Jun 12 20:33:41 CEST 2017
    rob...@syspatch-61-amd64.openbsd.org:
/usr/src/sys/arch/amd64/compile/GENERIC
real mem = 2130640896 (2031MB)
avail mem = 2061524992 (1966MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.5 @ 0xe1000 (10 entries)
bios0: vendor innotek GmbH version "VirtualBox" date 12/01/2006
bios0: innotek GmbH VirtualBox
acpi0 at bios0: rev 2
acpi0: sleep states S0 S5
acpi0: tables DSDT FACP APIC SSDT
acpi0: wakeup devices
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM)2 Duo CPU T7500 @ 2.20GHz, 2214.92 MHz
cpu0:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SSE3,MWAIT,SSSE3,NXE,LONG,LAHF
cpu0: 4MB 64b/line 16-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: CPU supports MTRRs but not enabled by BIOS
cpu0: apic clock running at 1000MHz
cpu0: mwait min=64, max=64
ioapic0 at mainbus0: apid 1 pa 0xfec00000, version 20, 24 pins
acpiprt0 at acpi0: bus 0 (PCI0)
acpicpu0 at acpi0: C1(@1 halt!)
"PNP0303" at acpi0 not configured
"PNP0F03" at acpi0 not configured
acpibat0 at acpi0: BAT0 model "1" serial 0 type VBOX oem "innotek"
acpiac0 at acpi0: AC unit online
acpivideo0 at acpi0: GFX0
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel 82441FX" rev 0x02
pcib0 at pci0 dev 1 function 0 "Intel 82371SB ISA" rev 0x00
pciide0 at pci0 dev 1 function 1 "Intel 82371AB IDE" rev 0x01: DMA, channel
0 configured to compatibility, channel 1 configured to compatibility
wd0 at pciide0 channel 0 drive 0: <VBOX HARDDISK>
wd0: 128-sector PIO, LBA48, 131072MB, 268435456 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
atapiscsi0 at pciide0 channel 1 drive 0
scsibus1 at atapiscsi0: 2 targets
cd0 at scsibus1 targ 0 lun 0: <VBOX, CD-ROM, 1.0> ATAPI 5/cdrom removable
cd0(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 2
vga1 at pci0 dev 2 function 0 "InnoTek VirtualBox Graphics Adapter" rev 0x00
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
virtio0 at pci0 dev 3 function 0 "Qumranet Virtio Network" rev 0x00
vio0 at virtio0: address 08:00:27:46:ae:39
virtio0: apic 1 int 19
"InnoTek VirtualBox Guest Service" rev 0x00 at pci0 dev 4 function 0 not
configured
ohci0 at pci0 dev 6 function 0 "Apple Intrepid USB" rev 0x00: apic 1 int
22, version 1.0
piixpm0 at pci0 dev 7 function 0 "Intel 82371AB Power" rev 0x08: apic 1 int
23
iic0 at piixpm0
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pms0 at pckbc0 (aux slot)
wsmouse0 at pms0 mux 0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
usb0 at ohci0: USB revision 1.0
uhub0 at usb0 configuration 1 interface 0 "Apple OHCI root hub" rev
1.00/1.00 addr 1
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
root on wd0a (68860b4005b03e59.a) swap on wd0b dump on wd0b

Reply via email to