Hi,

I am publishing a SearXNG instance using relayd. It works properly with
various graphical Web browsers and some text browsers. But when using
w3m, the search doesn't work. If I replace relayd with nginx, the search
works properly with w3m.

I read relay_http.c but I can't understand what happens. After using
tcpdump, I can only see that headers are not in the same order when
using links and w3m. But all headers seem to be present though.

When using `links http://example.com/`, the search works.

relayd log displays:
========================================================================
relayd[56706]: relay www, session 3 (1 active), 0, 192.168.0.95 -> 
127.0.0.1:8888, done, GET
relayd[58714]: relay www, session 1 (1 active), 0, 192.168.0.95 -> 
127.0.0.1:8888, done, POST   
========================================================================

tcpdump listening for POST queries displays:
========================================================================
01:51:23.433051 192.168.0.95.38080 > 192.168.0.64.www: P 
4100625321:4100626123(802) ack 1656575816 win 1027 <nop,nop,timestamp 
3076681497 2883586760> (DF)
E..V..@.@...
.._
..@...P.j..b.WH...........
.bo...
.POST /searxng/search HTTP/1.1
Host: example.com
User-Agent: Links (2.30; FreeBSD 14.2-RELEASE-p1 amd64; LLVM/Clang 18.1.5; text)
Referer: http://example.com/
Accept: */*
Accept-Language: fr,en;q=0.2,*;q=0.1
Accept-Encoding: gzip, deflate, br, zstd, bzip2, lzma, lzma2
Accept-Charset: 
us-ascii,ISO-8859-1,ISO-8859-2,ISO-8859-3,ISO-8859-4,ISO-8859-5,ISO-8859-6,ISO-8859-7,ISO-8859-8,ISO-8859-9,ISO-8859-10,ISO-8859-13,ISO-8859-14,ISO-8859-15,ISO-8859-16,windows-1250,windows-1251,windows-1252,windows-1256,windows-1257,cp437,cp737,cp850,cp852,cp866,x-cp866-u,x-mac,x-mac-ce,x-kam-cs,koi8-r,koi8-u,koi8-ru,TCVN-5712,VISCII,utf-8
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 79

q=netbsd&category_general=1&language=auto&time_range=&safesearch=0&theme=simple
========================================================================


When using `w3m http://example.com/`, the search doesn't work.
w3m gets a blank page as the response of its POSTs.

relayd log displays:
========================================================================
relayd[56706]: relay www, session 1 (1 active), 0, 192.168.0.95 -> 
127.0.0.1:8888, done, GET
relayd[56706]: relay www, session 2 (1 active), 0, 192.168.0.95 -> :0, no 
method, POST
========================================================================

tcpdump listening for POST queries displays:
========================================================================
01:50:33.462251 192.168.0.95.41172 > 192.168.0.64.www: P 
2604555521:2604555911(390) ack 4269652705 win 1027 <nop,nop,timestamp 
1706569526 739967719> (DF)
E.....@.@...
.._
..@...P.>]..}......z......
e./6,...POST /searxng/search HTTP/1.0
User-Agent: w3m/0.5.3+git20230718
Accept: text/html, text/*;q=0.5, image/*
Accept-Encoding: gzip, compress, bzip, bzip2, deflate, br
Accept-Language: en;q=1.0
Host: example.com
Referer: http://example.com/
Content-Type: application/x-www-form-urlencoded
Content-Length: 80

q=openbsd&category_general=1&language=auto&time_range=&safesearch=0&theme=simple
========================================================================

I've stripped down relayd.conf as much as possible and it looks like
this:
========================================================================
wan_ipv4 = "192.168.0.64"
localhost = "127.0.0.1"
sx_port    = "8888"

interval 5

log state changes
log connection errors
log connection

table <searxng>  { $localhost }

http protocol www {
        match request header set "X-Forwarded-For"   value "$REMOTE_ADDR"
        match request header set "X-Real-IP"         value "$REMOTE_ADDR"
        match request header set "X-Scheme"          value "https"
        match request header set "X-Script-Name"     value "/searxng"
}

relay www {
        listen on $wan_ipv4 port 80
        protocol www
        forward to <searxng>  port $sx_port
}
========================================================================

Is there a way to correct this and have w3m work?

Thanks for help,
Joel C.

Reply via email to