[UE] cgi-bin not working over ipv6
Added by kapiteined over 4 years ago
Hi,
I run a lighttpd server in a docker container with ipv6 enabled.
I am able to access the html part of the website using either the ipv6 or the ipv4 address of the container.
The cgi-bin part works OK when i use the ipv4 address but gives a 500 error when using the ipv6 address.
Can anyone confirm that cgi-bin (running a bash script ) does or does not work when you use the ipv6 address of a server?
I am using lighttpd/1.4.45
When using ipv4 i get:
wget --quiet -O - "http://172.17.0.2/cgi-bin/index.cgi?hello_world" 172.17.0.1 hello_world
and with using ipv6 i get:
wget -O - "http://[2a01:7e01:e002:9420:8888:242:ac11:2]/cgi-bin/index.cgi?hello_world" --2019-09-23 17:24:07-- http://[2a01:7e01:e002:9420:8888:242:ac11:2]/cgi-bin/index.cgi?hello_world Connecting to [2a01:7e01:e002:9420:8888:242:ac11:2]:80... connected. HTTP request sent, awaiting response... 500 Internal Server Error 2019-09-23 17:24:07 ERROR 500: Internal Server Error.
The html part works fine, so lightp is listening on ipv6.
using ipv4 for html i get:
wget --quiet -O - "http://172.17.0.2/index.html" <!DOCTYPE html> <html> <head> <META HTTP-EQUIV="Expires" content="Tue, 03 Jul 2001 06:00:00 GMT"> <META HTTP-EQUIV="Last-Modified" content="{now} GMT"> <META HTTP-EQUIV="cache-control" content="no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=1"> <META HTTP-EQUIV="pragma" content="no-cache"> </head> <body style="height: 100%;"> <style type='text/css'> "Nothing to seen here folks, move along..." </body> </html>
And using ipv6 i get:
wget --quiet -O - "http://[2a01:7e01:e002:9420:8888:242:ac11:2]/index.html" <!DOCTYPE html> <html> <head> <META HTTP-EQUIV="Expires" content="Tue, 03 Jul 2001 06:00:00 GMT"> <META HTTP-EQUIV="Last-Modified" content="{now} GMT"> <META HTTP-EQUIV="cache-control" content="no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=1"> <META HTTP-EQUIV="pragma" content="no-cache"> </head> <body style="height: 100%;"> <style type='text/css'> "Nothing to seen here folks, move along..." </body> </html>
cgi-bin/index.cgi is:
#!/bin/bash echo "${REMOTE_ADDR}" echo "${QUERY_STRING}"
Kind regards,
Ed
Replies (2)
RE: cgi-bin not working over ipv6 - Added by stbuehler over 4 years ago
Your wget examples are useless as you request a different URL (.html instead of .cgi).
Your script should respond with a proper CGI response, i.e. first a header block, then a body. If the first line doesn't look like a header (doesn't contain a ":"), lighttpd will assume an empty one with status 200, otherwise it will try to parse the header. IPv4 doesn't contain a ":", but IPv6 does - but an IPv6 address isn't a valid header.
Try starting output with printf 'Status: 200\r\nContent-Type: text/plain\r\n\r\n'
or something like that.
[SOLVED] RE: cgi-bin not working over ipv6 - Added by kapiteined over 4 years ago
Thanks so much!
Indeed the way too simple index.cgi was the culprit.
Adding a proper response fixed my problem.
Thanks again!
Kind regards,
Ed