Sign up here and you can log into the forum!

apache vhosts dhcp ip addresses

This is the place to ask for how to use software that is (or isn't) included in the various wdlxtv flavours. Questions about software such as rtorrent, NZBGet, sshfs, curlftpfs, ssh, telnet, etc.

apache vhosts dhcp ip addresses   

Postby KAD » Mon Aug 18, 2014 10:35 am

so I'll probably have a beta firmware posted up in the next few days

but since I have a few momments, some questions
that if nothing else might make some interesting discussion

I've implemented httpd-vhosts.conf in apache config, so that both wdlxtv-webend and official wd-webend can run at the same time

so I've got a couple of choices to make here
1. use name based addresses on vhosts.conf
- the problem with this is the webend has never run on name based, and after several quick test I was unable to get name based vhosts to work
- if I was to implement this, what would it take or is it worth while, I'd have to somehow report dns names to the dns server on the network (usually a router)
- addresses would look something like wdlxtv-webend.com & wd-webend.com

2. we can use IP based addresses in vhosts.conf
- this actually works quite well but presents some different issues
a. we have to get the WD's IP address into vhosts.conf at boot time and restart apache - done
b. we need to obtain a 2nd IP address and get that into vhosts
-1. preferably we would just get this via dhcp, so we are guaranteed not to create IP conflict on the network - but I don't know how to do this
-2. I can use nmap to get an IP list and iterate over it, and then randomly select an IP in the range that is not used - not implemented yet, but possible
-3. we can force users to manually add an IP on the wdlxtv webend, before we make the official webend available - for now this is in place

but your thoughts/opinions about a setup like this

initially testing shows the final option of 2.b.3 having users input the address manually seems to work ok
but functionality and features of the official webend of coarse are not available until a users do so
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: apache vhosts dhcp ip addresses   

Postby mad_ady » Mon Aug 18, 2014 11:48 pm

For option #2, you can try to use dhcp to allocate a secondary IP to a secondary network interface. You can create your secondary network interface like this:

Code: Select all
ifconfig eth0:1 up
dhclient eth0:1 &


However, it presents the following problems:
1. It assumes a DHCP server exists on the network. Some networks might have DHCP turned off.
2. If the DHCP server is configured to assign an IP statically (based on the MAC), then having a secondary IP on the network interface will not work (you'd get the same IP as the primary interface). I think you can assign a different MAC address on eth0:1, but you'd run into problem #4.
3. You would need to find out what network interface is active (eth or wlan)
4. If the user has multiple SMPs in the network, all running your firmware, using a DNS based approach will not work, since both devices will try to register with the same name (or in case of #2, the same MAC).

Using nmap to scan for a free IP is a bad idea, mostly because you might find an IP which is reported as free, but is statically allocated (or is part of a DHCP pool) to a host which is offline when the scan is performed. When the host becomes online, boom - IP conflict.

So, there's no easy solution to this problem. Having the user specify an IP sounds like the best option, to avoid lots of headaches.

I guess I'll have to do a similar approach for 1.06 firmware, which has its own web interface. I'll try to do it the same way you did, for consistency (but first, I have to start working on the port) :)
User avatar
mad_ady
Developer
 
Posts: 4545
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: apache vhosts dhcp ip addresses   

Postby KAD » Tue Aug 19, 2014 8:11 am

actually problem 3 is also a problem with having the user manually assign an IP address
we have to know if we're using eth0 or wlan0
but that wasn't that difficult
ifconfig will list the interfaces
but only the active interface will have an IP address so a few cut's and grep and we can check if the interface has an IP address or not
and then create eth0:0 or wlan0:0 on whichever interface already has an IP address

just a couple other random thoughts
why doesn't it work to just add the wd-webend as a plugin to wdlxtv-webend
the way wd-webend was written require the scripts to be run from an address like this http://192.168.1.25
if we try to run it from http://192.168.1.25/wd or anything similiar the path is not the same
and functionality is broken as it can't locate the correct scripts needed, so really the only option to run both is using vhosts

and this is also this reason that alias option for apache does not work as well
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: apache vhosts dhcp ip addresses   

Postby mad_ady » Wed Aug 20, 2014 1:45 am

Hmm, about the webend, you'd have to ask RMerlin. However, even if you manage to fix it easily, it's possible that some other scripts have hardcoded values that point to http://$ip/path (e.g. umsp).
User avatar
mad_ady
Developer
 
Posts: 4545
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: apache vhosts dhcp ip addresses   

Postby KAD » Wed Aug 20, 2014 7:24 am

mad_ady wrote:Hmm, about the webend, you'd have to ask RMerlin. However, even if you manage to fix it easily, it's possible that some other scripts have hardcoded values that point to http://$ip/path (e.g. umsp).


lol, my point was, why don't I do something easier - because the easier known methods don't work
that's why I'm looking at vhosts because they do work - because they do resolve and fix any path related issues

after some updates last night, I'm comfortable with my current vhosts implementation
now just to fix app.bin support and I'll post up that beta
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA


Return to Application Questions

Who is online

Users browsing this forum: No registered users and 1 guest