gitit icon indicating copy to clipboard operation
gitit copied to clipboard

config option to set listen address

Open infinity0 opened this issue 15 years ago • 13 comments

please add a config option to set the listen address - this would provide an easy way of setting up a private wiki over a lan or vpn

infinity0 avatar May 15 '10 18:05 infinity0

... or your very own localhost wiki

dhouthoo avatar Jul 06 '10 13:07 dhouthoo

i've implemented this very quickly here http://github.com/infinity0/gitit/commit/6b78a012789680985584427bee0ae89220a25514

I don't know ANY haskell; i did this with various online references. it's ugly but it compiles and works, if you need this functionality right now.

the interface address is hard-coded into the source code. also, i have no idea what line 84 (listen sock 10) does - i'm guessing accept a maximum of 10 concurrent incoming connections.

someone with a better knowledge of haskell might want to make this a setting you can edit in the config file.

infinity0 avatar Jul 06 '10 17:07 infinity0

I have extended this a bit, the listen address is now configurable via command line option: http://github.com/tbh/gitit/commit/c3c7d6919b8c4d4a4c27b8825e4c2d151bd0c670

tbk303 avatar Aug 09 '10 12:08 tbk303

I needed this feature as well. tbh's patch works for me (thanks!)

sporksmith avatar Sep 15 '10 02:09 sporksmith

Yes. I need this also and I'm using the tbh's patch (thanks too!).

dixie avatar Jan 26 '11 14:01 dixie

Thanks, I've merged tbh's patch. I'll modify it later to allow setting the listen address in the config file, so I'm keeping this issue open to remind myself...

jgm avatar Mar 30 '11 01:03 jgm

is the default supposed to be 127.0.0.1?

$ gitit & 
$ netstat -ltnp | grep gitit
tcp        0      0 127.0.0.1:5001          0.0.0.0:*               LISTEN      17495/gitit     
$ gitit -l 0.0.0.0 & 
$ netstat -ltnp | grep gitit
tcp        0      0 0.0.0.0:5001            0.0.0.0:*               LISTEN      17503/gitit     

also ipv6 doesn't seem to work:

$ gitit -l ::1
gitit: user error (inet_addr: Malformed address: ::1)

(also, this brings up the bug that atm there's no way to listen on both IPv4 and IPv6)

$ gitit --version
gitit version 0.8 -plugins
Copyright (C) 2008 John MacFarlane
This is free software; see the source for copying conditions.  There is no
warranty, not even for merchantability or fitness for a particular purpose.

infinity0 avatar Jun 14 '11 20:06 infinity0

Yes, 127.0.0.1 is the default. Do you think the default should be something else? As for ipv6, I don't know enough about the low-level networking libraries to fix this at the moment, but I'd happily accept a patch to improve things.

jgm avatar Jun 20 '11 18:06 jgm

iirc the previous behaviour was to listen on 0.0.0.0, so it should remain the same? i think network daemons generally listen on that by default, and serving a public wiki is probably the most common use-case.

infinity0 avatar Jul 02 '11 16:07 infinity0

Right, I'll change the default to 0.0.0.0.

I'd welcome a patch to fix ip6 and make it possible to listen on ip4 and ip6 simultaneously. tbh?

jgm avatar Jul 05 '11 11:07 jgm

Did this make it to a config file option yet? I have "listen: 127.0.0.1" in the config file but gitit still bound to 0.0.0.0

focusaurus avatar Apr 29 '12 15:04 focusaurus

No, but it's available as a command line option.

+++ Peter Lyons [Apr 29 12 08:22 ]:

Did this make it to a config file option yet? I have "listen: 127.0.0.1" in the config file but gitit still bound to 0.0.0.0


Reply to this email directly or view it on GitHub: https://github.com/jgm/gitit/issues/10#issuecomment-5405699

jgm avatar Apr 29 '12 16:04 jgm

For the record, gitit 0.13.0.0 in Debian 11 currently only binds to legacy IP, not stable IP.

$ sudo ss -l6p | grep -e Local -e gitit
Netid State  Recv-Q Send-Q Local Address:Port          Peer Address:PortProcess     
$ sudo ss -l4p | grep -e Local -e gitit
Netid State  Recv-Q Send-Q Local Address:Port          Peer Address:PortProcess                                                                                                                                        
tcp   LISTEN 0      10           0.0.0.0:5001               0.0.0.0:*    users:(("gitit",pid=4162986,fd=12))   

This confused me briefly, because when nginx is told "reverse-proxy localhost:5001", "localhost" resolves to both ::1 and 127..1. The former causes whinging in /var/log/nginx/error.log. The users don't notice because (I guess) nginx automatically falls back to legacy IP.

2022/11/17 07:10:03 [error] 1818696#1818696: *106 connect() failed (111: Connection refused) while connecting to upstream, client: 203.7.155.2, server: kb.cyber.com.au, request: "GET / HTTP/1.1", upstream: "http://[::1]:5001/", host: "kb.cyber.com.au"
2022/11/17 07:25:15 [error] 1818696#1818696: *167 connect() failed (111: Connection refused) while connecting to upstream, client: 203.7.155.2, server: kb.cyber.com.au, request: "GET / HTTP/1.1", upstream: "http://[::1]:5001/", host: "kb.cyber.com.au"
2022/11/17 07:40:27 [error] 1818696#1818696: *217 connect() failed (111: Connection refused) while connecting to upstream, client: 203.7.155.2, server: kb.cyber.com.au, request: "GET / HTTP/1.1", upstream: "http://[::1]:5001/", host: "kb.cyber.com.au"
2022/11/17 07:55:39 [error] 1818696#1818696: *267 connect() failed (111: Connection refused) while connecting to upstream, client: 203.7.155.2, server: kb.cyber.com.au, request: "GET / HTTP/1.1", upstream: "http://[::1]:5001/", host: "kb.cyber.com.au"
2022/11/17 08:10:52 [error] 1818696#1818696: *366 connect() failed (111: Connection refused) while connecting to upstream, client: 203.7.155.2, server: kb.cyber.com.au, request: "GET / HTTP/1.1", upstream: "http://[::1]:5001/", host: "kb.cyber.com.au"
2022/11/17 08:26:04 [error] 1818696#1818696: *413 connect() failed (111: Connection refused) while connecting to upstream, client: 203.7.155.2, server: kb.cyber.com.au, request: "GET / HTTP/1.1", upstream: "http://[::1]:5001/", host: "kb.cyber.com.au"
2022/11/17 08:41:16 [error] 1818696#1818696: *469 connect() failed (111: Connection refused) while connecting to upstream, client: 203.7.155.2, server: kb.cyber.com.au, request: "GET / HTTP/1.1", upstream: "http://[::1]:5001/", host: "kb.cyber.com.au"
2022/11/17 08:56:28 [error] 1818696#1818696: *531 connect() failed (111: Connection refused) while connecting to upstream, client: 203.7.155.2, server: kb.cyber.com.au, request: "GET / HTTP/1.1", upstream: "http://[::1]:5001/", host: "kb.cyber.com.au"
2022/11/17 09:11:40 [error] 1818696#1818696: *631 connect() failed (111: Connection refused) while connecting to upstream, client: 203.7.155.2, server: kb.cyber.com.au, request: "GET / HTTP/1.1", upstream: "http://[::1]:5001/", host: "kb.cyber.com.au"
2022/11/17 09:26:52 [error] 1818696#1818696: *682 connect() failed (111: Connection refused) while connecting to upstream, client: 203.7.155.2, server: kb.cyber.com.au, request: "GET / HTTP/1.1", upstream: "http://[::1]:5001/", host: "kb.cyber.com.au"

Trying to explicitly bind to a stable IP address gives an error:

twb@heavy:~$ with-temp-dir gitit -p55555 -l::1
with-temp-dir: entering directory `/tmp/with-temp-dir.QLP7Ry'
Created repository in wikidata
Added Front Page.page to repository
Added Help.page to repository
Added Gitit User’s Guide.page to repository
Created static/css/custom.css
Created static/img/logo.png
Created templates/footer.st
gitit: Network.Socket.bind: unsupported operation (Address family not supported by protocol)

trentbuck avatar Nov 16 '22 22:11 trentbuck