Page 1 of 1

[Solved] mini_httpd in jail : "bind: Address already in use"

Posted: 14 Jul 2013 21:18
by jensting
EDIT: Don't know what made it work, but it appears that mini_httpd was starting at the start of the jail (which makes sense, I guess, in particular since the instructions I followed did include adding mini_httpd somewhere in the /etc/ hierachy of control file) and the error message was mini_httpd's way of telling me that it had been started twice. Why it didn't look in the /var/run/mini_httpd.pid I do not know...

So, between only starting once and putting explicit address (or host name) for various "server_bind" like options in the service I run on the host, I now have mini_httpd in a jail with no error message. That's nice.

Thanks for taking the time to read this and for the tips which were very educational.

Best Regards

Jens
====================
Dear all,

I found minidlna so easy to put in a jail (using The Brig) that I got cocky and tried for BackupPC. (I have not used BackupPC before, but it sounded right - if there are other solutions allowing backup from PCs and Linux boxes which are known to work in nas4free jails, I'm all ears).

So, I had a look at http://sourceforge.net/apps/mediawiki/b ... Mini_httpd which sounded like just the thing.

Inside a brand new jail (full + src) I ran

Code: Select all

setenv PACKAGESITE ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.1-release/Latest/
pkg_add -rv mini_httpd
pw groupadd backuppc -g 800
pw useradd backuppc -u 800 -s /usr/local/bin/bash -d /usr/local/BackupPC -m
Created a /usr/local/www/mini_httpd_config file containing

Code: Select all

user=backuppc
dir=/usr/local/www/backuppc
cgipat=cgi-bin/*
logfile=/var/log/mini_httpd.log
pidfile=/var/run/mini_httpd.pid
port=2359
#ssl
certfile=/usr/local/etc/ssl/certs/domain.com/server.pem
#debug
ran

Code: Select all

mkdir -p /usr/local/www/backuppc/cgi-bin
htpasswd -c /usr/local/www/backuppc/cgi-bin/.htpasswd username
chown -R backuppc:backuppc /usr/local/www/backuppc
(OK, that should probably not be explicit "username" above, but we'll let that pass)

and I believe I should be ready to try out the instalkled mini_httpd (which does show up as installed, no problem).

Code: Select all

/usr/local/etc/rc.d/mini_httpd.sh start
Which does not go well... I get

Code: Select all

 mini_httpdroot@backuppc:/ # bind: Address already in use
/usr/local/sbin/mini_httpd: can't bind to any address
repeated endlessly and nothing responding when I try to talk to the server.

While I'm sure I missed something (notably the "username" which should probably be "backuppc" without the quotes) the bind error sounds fatal.

The jail options are the first two boxes under "mount" but not procfs and fdescfs .

So, any input welcome!

Best Regards

Jens

Re: trouble installing backupPC in jail: mini_httpd no `bind

Posted: 14 Jul 2013 22:20
by alexey123
If you use NAS4Free webserver, try add to Auxiliary parameters value

Code: Select all

server.bind = "Your_nas_IP"
With quotes

Re: trouble installing backupPC in jail: mini_httpd no `bind

Posted: 15 Jul 2013 07:45
by jensting
alexey123 wrote:If you use NAS4Free webserver, try add to Auxiliary parameters value

Code: Select all

server.bind = "Your_nas_IP"
With quotes
OK, that's for the webserver in the nas4free. I don't know how that works with the jail. And then I don't know how BackupPC works with the web server, but I hope to find this out.

So, can the nas4free web server work with the jail?

Re: trouble installing backupPC in jail: mini_httpd no `bind

Posted: 15 Jul 2013 08:43
by jensting
Quick update: by actually adding the SSL certificate and staying exactly with the guide from SourceForge, I got the mini_httpd server to work.
Great! On to getting BackupPC configured.

Re: [SOLVED] installing backupPC in jail: mini_httpd no `bin

Posted: 15 Jul 2013 09:40
by alexey123
For run jails on NAS4Free you need prepare host before add software.
For webgui I use https protocol
For another services I wrote post here
Enjoy

Re: [SOLVED] installing backupPC in jail: mini_httpd no `bin

Posted: 17 Jul 2013 08:04
by jensting
alexey123 wrote:For run jails on NAS4Free you need prepare host before add software.
For webgui I use https protocol
For another services I wrote post here
Enjoy
I see what you mean - the host system is already serving the address that the server in the jail wants to serve.

OK. I inserted my host specific IP number as extra options in the services I do start (SSH, FTP, SAMBA/CIFS and AFP). I get a few log file messages which indicate no complaints and even sometime indicate that the specific address is used.

That didn't remove the message about "bind: Address already in use"

I then added an option to the server in the jail to only serve the jail IP address, in /usr/local/www/mini_httpd_config

Code: Select all

host=192.168.0.102
That still didn't remove the error message.

Since the regular WebGUI page still works and the mini_httpd server also works, I'm not very worried at this stage.

Re: installing backupPC in jail: mini_httpd no `bind'

Posted: 20 Jul 2013 09:54
by jensting
Sorry, it is not solved, I still get an error message and opening the webpage running on the jail takes tens of seconds (which I'm assuming is linked to severeal addresses being tried - there is no such delay when accessing the WebGUI).
Once I have a page back from the server, it is as responsive as a normal webpage.

Re: Running mini_httpd in jail : "bind: Address already in u

Posted: 20 Jul 2013 11:14
by jensting
Update: I tried switching off services, one at a time, to see if the error from bind went away. It didn't.

(For the record, I have CIFS/SMB, FTP, SSH, AFP and UPS running.)

So, could the error come from the built-in webserver (serving the WebGUI)?

Is there a way of restricting the built-in servers to only respond in the address range where the jail IPs do not live?

Re: Running mini_httpd in jail : "bind: Address already in u

Posted: 20 Jul 2013 18:23
by raulfg3

Re: Running mini_httpd in jail : "bind: Address already in u

Posted: 21 Jul 2013 09:18
by jensting
Thanks, but... I did try disabling SMB and still got the problem. I continue to get the problem if I use these options, but at least "bind interface only" sounds like a good idea, and I'm also using name rather than IP address, so it's better in the overall scheme but didn't solve the immediate issue.

Code: Select all

bind interfaces only = YES
interfaces = nas4free.local
smb ports = 139
I keep wondering if there's something similar for the built-in webserver?

Re: Running mini_httpd in jail : "bind: Address already in u

Posted: 21 Jul 2013 17:30
by jensting
Also, I had a look at what I think is the setup file for the host (not the jail) WebGUI built-in webserver (lighthttpd), in /var/etc/lighttpd.conf

Code: Select all

server.bind = "192.168.0.47"
server.port = "80"

Re: [Solved?]mini_httpd in jail : "bind: Address already in

Posted: 22 Jul 2013 10:00
by alexey123
jensting, I can not help you now, but if you can wait 10-11 days, I'll wrote help for you

Re: [Solved?]mini_httpd in jail : "bind: Address already in

Posted: 23 Jul 2013 07:47
by fsbruva
Please type the following on your N4F host (not inside the jail):

Code: Select all

sockstat -l46
This should list (-l) all the sockets (sockstat) in use, and their IP addresses (46).

Then see what service is currently running on the IP you want to start mini_httpd on. Also, it's not just address, but port as well. It could be you think 192.168.0.47:80 is available, but it's not.

Re: [Solved?]mini_httpd in jail : "bind: Address already in

Posted: 23 Jul 2013 17:53
by jensting
fsbruva wrote:Please type the following on your N4F host (not inside the jail):

Code: Select all

sockstat -l46
This should list (-l) all the sockets (sockstat) in use, and their IP addresses (46).

Then see what service is currently running on the IP you want to start mini_httpd on. Also, it's not just address, but port as well. It could be you think 192.168.0.47:80 is available, but it's not.
Without backuppc jail running:

Code: Select all

nas4free: ~ # sockstat -l46
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
root     mDNSRespon 31268 3  udp4   *:39621               *:*
root     mDNSRespon 31268 4  udp4   *:5353                *:*
root     cnid_metad 31233 3  tcp6   ::1:4700              *:*
root     afpd       31230 4  tcp4 6 *:548                 *:*
dlna     minidlna   2499  5  udp4   192.168.0.128:1900    *:*
dlna     minidlna   2499  6  tcp4   192.168.0.128:8200    *:*
dlna     minidlna   2499  7  udp4   192.168.0.128:33307   *:*
root     mDNSRespon 2266  3  udp4   *:30218               *:*
root     mDNSRespon 2266  4  udp4   *:5353                *:*
root     lighttpd   2154  4  tcp4   192.168.0.47:80       *:*
root     lighttpd   2154  5  tcp6   fe80:1::2a92:4aff:fe30:5e8a:80 *:*
root     sshd       1978  4  tcp4   192.168.0.47:22       *:*
root     smbd       1939  26 tcp4   192.168.0.47:139      *:*
root     nmbd       1936  9  udp4   *:137                 *:*
root     nmbd       1936  10 udp4   *:138                 *:*
root     nmbd       1936  11 udp4   192.168.0.47:137      *:*
root     nmbd       1936  12 udp4   192.168.0.255:137     *:*
root     nmbd       1936  13 udp4   192.168.0.47:138      *:*
root     nmbd       1936  14 udp4   192.168.0.255:138     *:*
nobody   proftpd    1819  2  tcp4 6 *:21                  *:*
root     upsd       1753  4  tcp6   ::1:3493              *:*
root     upsd       1753  5  tcp4   127.0.0.1:3493        *:*
root     rpc.statd  1619  4  udp6   *:902                 *:*
root     rpc.statd  1619  5  tcp6   *:902                 *:*
root     rpc.statd  1619  6  udp4   *:902                 *:*
root     rpc.statd  1619  7  tcp4   *:902                 *:*
root     nfsd       1615  5  tcp4   *:2049                *:*
root     nfsd       1615  6  tcp6   *:2049                *:*
root     mountd     1603  5  udp6   *:731                 *:*
root     mountd     1603  6  tcp6   *:731                 *:*
root     mountd     1603  7  udp4   *:731                 *:*
root     mountd     1603  8  tcp4   *:731                 *:*
root     rpcbind    1572  4  udp6   *:*                   *:*
root     rpcbind    1572  6  udp6   *:111                 *:*
root     rpcbind    1572  7  udp6   *:998                 *:*
root     rpcbind    1572  8  tcp6   *:111                 *:*
root     rpcbind    1572  9  udp4   *:111                 *:*
root     rpcbind    1572  10 udp4   *:612                 *:*
root     rpcbind    1572  11 tcp4   *:111                 *:*
?        ?          ?     ?  udp6   *:821                 *:*
?        ?          ?     ?  udp4   *:627                 *:*
?        ?          ?     ?  udp6   *:2049                *:*
?        ?          ?     ?  udp6   *:601                 *:*
?        ?          ?     ?  tcp4   *:629                 *:*
?        ?          ?     ?  udp4   *:2049                *:*
?        ?          ?     ?  udp4   *:*                   *:*
?        ?          ?     ?  tcp6   *:615                 *:*
With backuppc jail running:

Code: Select all

nas4free: ~ # sockstat -l46
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
800      mini_httpd 35511 5  tcp4   192.168.0.129:2359    *:*
root     mDNSRespon 31268 3  udp4   *:39621               *:*
root     mDNSRespon 31268 4  udp4   *:5353                *:*
root     cnid_metad 31233 3  tcp6   ::1:4700              *:*
root     afpd       31230 4  tcp4 6 *:548                 *:*
dlna     minidlna   2499  5  udp4   192.168.0.128:1900    *:*
dlna     minidlna   2499  6  tcp4   192.168.0.128:8200    *:*
dlna     minidlna   2499  7  udp4   192.168.0.128:33307   *:*
root     mDNSRespon 2266  3  udp4   *:30218               *:*
root     mDNSRespon 2266  4  udp4   *:5353                *:*
root     lighttpd   2154  4  tcp4   192.168.0.47:80       *:*
root     lighttpd   2154  5  tcp6   fe80:1::2a92:4aff:fe30:5e8a:80 *:*
root     sshd       1978  4  tcp4   192.168.0.47:22       *:*
root     smbd       1939  26 tcp4   192.168.0.47:139      *:*
root     nmbd       1936  9  udp4   *:137                 *:*
root     nmbd       1936  10 udp4   *:138                 *:*
root     nmbd       1936  11 udp4   192.168.0.47:137      *:*
root     nmbd       1936  12 udp4   192.168.0.255:137     *:*
root     nmbd       1936  13 udp4   192.168.0.47:138      *:*
root     nmbd       1936  14 udp4   192.168.0.255:138     *:*
nobody   proftpd    1819  2  tcp4 6 *:21                  *:*
root     upsd       1753  4  tcp6   ::1:3493              *:*
root     upsd       1753  5  tcp4   127.0.0.1:3493        *:*
root     rpc.statd  1619  4  udp6   *:902                 *:*
root     rpc.statd  1619  5  tcp6   *:902                 *:*
root     rpc.statd  1619  6  udp4   *:902                 *:*
root     rpc.statd  1619  7  tcp4   *:902                 *:*
root     nfsd       1615  5  tcp4   *:2049                *:*
root     nfsd       1615  6  tcp6   *:2049                *:*
root     mountd     1603  5  udp6   *:731                 *:*
root     mountd     1603  6  tcp6   *:731                 *:*
root     mountd     1603  7  udp4   *:731                 *:*
root     mountd     1603  8  tcp4   *:731                 *:*
root     rpcbind    1572  4  udp6   *:*                   *:*
root     rpcbind    1572  6  udp6   *:111                 *:*
root     rpcbind    1572  7  udp6   *:998                 *:*
root     rpcbind    1572  8  tcp6   *:111                 *:*
root     rpcbind    1572  9  udp4   *:111                 *:*
root     rpcbind    1572  10 udp4   *:612                 *:*
root     rpcbind    1572  11 tcp4   *:111                 *:*
?        ?          ?     ?  udp6   *:821                 *:*
?        ?          ?     ?  udp4   *:627                 *:*
?        ?          ?     ?  udp6   *:2049                *:*
?        ?          ?     ?  udp6   *:601                 *:*
?        ?          ?     ?  tcp4   *:629                 *:*
?        ?          ?     ?  udp4   *:2049                *:*
?        ?          ?     ?  udp4   *:*                   *:*
?        ?          ?     ?  tcp6   *:615                 *:*
But, like I EDITed at the first post, I think I did not actually have a problem: The error message was mini_httpd's way of telling me that it was already running. I just wasn't checking if it were (i.e. it was starting automatically as per the instructions in the installed configuration files and I was manually starting it also).

Best Regards

Jens

Re: [Solved] mini_httpd in jail : "bind: Address already in

Posted: 26 Jul 2013 17:24
by alexey123
OK, I( made test install for backup pc - only server, without clients).
My NAS4Free webui use https protocol
My webserver use port 80 and http protocol

Mini_httpd run without problem, just I not start

Code: Select all

/usr/local/etc/rc.d/mini_httpd.sh start
I restart jail, and mini_httpd restart automatically.

I attach baccuppc admin screenshot
Image