Apache and web page view-ability

Hello to all!

First of all i must say that i’m new to these kind of stuff, so please be gentle :stuck_out_tongue:

This is my case(and the 3 questions):

I have installed and configured in the first place, php, apache2 and mysql in an opensuse 12.
I have successfully seen the html page i wanted through the pc with apache and through other pc’s in the same lan.
Here the problems start: to access the html page on apache from the same pc or other in the same lan, i have to put the ip address of the pc with apache on the address bar. For example:

  • On the pc with apache i can see the page through the address 192.168.1.3/page.html or forensick/page.html (i added the line 192.168.1.3 forensick in the /etc/hosts file). So far, so good.
  • On the other pc on the lan, i went to the same file, added the line and everything works like a charm.

The problem with this “configuration” is that the page depends on the ip of the pc with apache. If for example that pc connects with a different ip, i ll have to change the above files. I have looked over the internet (and here too), but i couldnt find something that works for me. I guess the word is VirtualServer, but i havent figured out how to do it. How do i assign a different ip address for the server in this lan(whenever i did it - i suppose the wrong way - i wasnt able to access the page not even from the apache pc)? On another pc on the lan, can i see the page.html without editing the hosts file?

The third question: Lets suppose that the above question is solved. Is there any possibility that the apache would work if its connected to a no-ip.biz address?

Thank you for your time!

> I have installed and configured in the first place, php, apache2 and
> mysql in an opensuse 12.
> I have successfully seen the html page i wanted through the pc with
> apache and through other pc’s in the same lan.

Great, so layers one through four are working, and even layer seven is
working, so nothing blocking. Good start.

> Here the problems start: to access the html page on apache from the
> same pc or other in the same lan, i have to put the ip address of the pc
> with apache on the address bar. For example:
> - On the pc with apache i can see the page through the address
> -192.168.1.3/page.html -or- forensick/page.html- (i added the line
> -192.168.1.3 forensick- in the /etc/hosts file). So far, so good.
> - On the other pc on the lan, i went to the same file, added the line
> and everything works like a charm.

Yes, as it should.

> The problem with this “configuration” is that the page depends on the
> ip of the pc with apache. If for example that pc connects with a
> different ip, i ll have to change the above files. I have looked over
> the internet (and here too), but i couldnt find something that works for

What I think you are wondering about is how to handle name resolution,
specifically getting to your machine’s IP address regardless of what that
IP address is. Often this is handled with DNS (Domain Name System) which
resolves from names to IP addresses; for example, you go not explicitly
put in an IP address to go o www.google.com, but instead your browser asks
your OS to figure out which IP address is associated with www.google.com
and then the browser goes to that IP address. Short of using DNS hacking
the /etc/hosts file is a shortcut that is from the days before DNS. These
days what you need is to setup a DNS entry on your DNS server (or your
ISP’s DNS server if doing something publicly) that will resolve to your IP
address from your DNS name. When you, then, go to www.whatever.biz DNS
will point your browser to something like 192.168.1.3. How you implement
this is up to you; DNS services are available within openSUSE fairly
simply, but that will only work with your IP address above if you are on
your local network. To access your system from anywhere in the world
you’ll need a public IP, to modify a public DNS server, and will then need
to make that public IP somehow get to your box with your web server.

> me. I guess the word is VirtualServer, but i havent figured out how to
> do it. How do i assign a different ip address for the server in this
> lan(whenever i did it - i suppose the wrong way - i wasnt able to access
> the page not even from the apache pc)? On another pc on the lan, can i
> see the page.html without editing the hosts file?

VirtualHost (guessing you mean that instead of VirtualServer) techniques
apply at some level, but what you’re asking about now (how to work around
hacking /etc/hosts all of the time) is all about DNS.

> The third question: Lets suppose that the above question is solved. Is
> there any possibility that the apache would work if its connected to a
> no-ip.biz address?

Definitely. The majority of the world’s web services are Apache
httpd-based, so all you need to do is configure name resolution
(www.whatever.biz to point to 192.168.1.3) and then the rest is pretty easy.

Describe a bit more about your end goal. Will this only apply on your
local network or will this be Internet-available? What is your current
DNS server, as found via the following command:

Code:

grep -v ‘^#’ /etc/resolv.conf

Will you have just one website on this machine, or multiples that should
be different via different DNS names (www.whatever.biz, mail.whatever.biz,
wordpress.whatever.biz, etc.) which is the basic case for VirtualHost stuff?

Good luck.

First of all, thank you very much for your extended answer(and sorry for the long post that you are going to see right now…)!

The original project is something else:
I want to setup a server which will have a STATIC wan ip address and I want it to communicate with hosts (they wont be in the same lan) who will be at a completely different place. These hosts will send specific data to the server to be stored(and i want to control these hosts from the server, but that’s a totally different thing from this topic).

The reasons that I devided this problem to 2 completely other are two:
1)I want to understand as many details I can about the functionality of the apache server. I suppose that first of all I have to understand how it works in a single lan.
2)After learning in some detail the lan procedures of apache, I then want to implement it in the internet. Because I don’t have the time (unfortunately) to go where the static ip address is, I thought that it would be close to implement it using no-ip, which site will somehow be connected to the pc with apache.

I don’t know if this is the right order, but that’s how I thought it.

I will divide my questions to local and non-local:

Local:
The final goal that I have in my mind for the lan network is to try to give to the server a different ip address than the one that of the pc which have it. Lets say that my router is 192.168.1.1. Every machine that is connected to this lan, takes an ip address 192.168.1.x.This address will not be more than 192.168.1.10 because usually there are not that many devices connected in this lan. So how can I give a different ip to the apache from the pc that is installed on? If this can be done, can I access that web page from another pc on this lan, by adding to the hosts file the new ip of the server or it has to have the ip of the pc that has apache? If the answer is still DNS, then please give me some hints, because i really dont know where to start with.

Another question here is this: in the /etc/hosts file in opensuse I have changed the localhost to forensick and added a new line “192.168.1.3 name”. So from the pc with apache, the page is viewable with many ways: 127.0.0.1/page.html, forensic/page.html, 192.168.1.3/page.html and finally name/page.html.
From the other pc (it has xp on), when I modify the hosts file, I put the ip address of the pc with apache and then a name. Lets say its “192.168.1.3 something”.
The thing that I noticed is that the only way to access the page.html from the other pc is to put on the browser either 192.168.1.3/page.html or something/page.html, but not the names that I used in the pc with apache. So in a way, the other pc directs to 192.168.1.3 and then it understands that it has to do with a web page in that address. Is there a way to access it using for example “forensick/page.html” (i suppose the answer here is dns)?

Non-Local:
I suppose that if some questions are answered for the local configuration, some will apply to this configuration too. So there is a no-ip domain name, which I want to relate it to the apache server which have a dynamic ip address. Ofcourse in this case I want to see the apache server from everywhere.

To answer your questions about the previous post:

> me. I guess the word is VirtualServer, but i havent figured out how to
> do it. How do i assign a different ip address for the server in this
> lan(whenever i did it - i suppose the wrong way - i wasnt able to access
> the page not even from the apache pc)? On another pc on the lan, can i
> see the page.html without editing the hosts file?

VirtualHost (guessing you mean that instead of VirtualServer) techniques
apply at some level, but what you’re asking about now (how to work around
hacking /etc/hosts all of the time) is all about DNS.

Yes, I meant VirtualHost, you are right ofcourse. I don’t really know what exactly am I asking, but I think that the Local part above, have made it a bit more clear.

Describe a bit more about your end goal. Will this only apply on your
local network or will this be Internet-available?

As I said, I firstly want to understand it in a local way and then apply it to the internet.

Will you have just one website on this machine, or multiples that should
be different via different DNS name

As I have understood by now, I will have only one website on this machine, which will be a server for some hosts(wan) to send their data.

The replay to the given command was:
*search site
nameserver 192.168.1.1

*Once again, thank you for your time!

forensick wrote:
> First of all, thank you very much for your extended answer(and sorry for
> the long post that you are going to see right now…)!
>
> The original project is something else:
> I want to setup a server which will have a STATIC wan ip address and I
> want it to communicate with hosts (they wont be in the same lan) who
> will be at a completely different place. These hosts will send specific
> data to the server to be stored.
>
> The reasons that I devided this problem to 2 completely other are two:
> 1)I want to understand as many details I can about the functionality of
> the apache server. I suppose that first of all I have to understand how
> it works in a single lan.

Yes, that’s a good idea.

> 2)After learning in some detail the lan procedures of apache, I then
> want to implement it in the internet. Because I don’t have the time
> (unfortunately) to go where the static ip address is, I thought that it
> would be close to implement it using no-ip, which site will somehow be
> connected to the pc with apache.

You mean that your web server will be somewhere that you are not? (i.e.
probably hosted somewhere?) That’s not really a problem as long as you
have ssh access to it, or some equivalent. It is important to be able to
access a client (browser) that is in a different place to the server on
the Internet, so as to check that DNS, and firewalls, and routing etc
are all working properly.

> I don’t know if this is the right order, but that’s how I thought
> it.
>
> I_will_divide_my_questions_to_local_and_non-local:
>
> Local:
> The final goal that I have in my mind for the lan network is to try to
> give to the server a different ip address than the one that of the pc
> which have it. Lets say that my router is 192.168.1.1. Every machine
> that is connected to this lan, takes an ip address 192.168.1.x.This
> address will not be more than 192.168.1.10 because usually there are not
> that many devices connected in this lan. So how can I give a different
> ip to the apache from the pc that is installed on? If this can be done,
> can I access that web page from another pc on this lan, by adding to the
> hosts file the new ip of the server or it has to have the ip of the pc
> that has apache? If the answer is still DNS, then please give me some
> hints, because i really dont know where to start with.

There are ways to do that, but it’s an unnecessary complexity. What is
it that you think you will learn? Why did you think to do this?

> Another question here is this: in the /etc/hosts file in opensuse I
> have changed the localhost to forensick and added a new line
> “192.168.1.3 name”. So from the pc with apache, the page is
> viewable with many ways: 127.0.0.1/page.html, forensic/page.html,
> 192.168.1.3/page.html and finally name/page.html.
> From the other pc (it has xp on), when I modify the hosts file, I put
> the ip address of the pc with apache and then a name. Lets say its
> “192.168.1.3 something”.
> The thing that I noticed is that the only way to access the page.html
> from the other pc is to put on the browser either 192.168.1.3/page.html
> or something/page.html, but not the names that I used in the pc with
> apache. So in a way, the other pc directs to 192.168.1.3 and then it
> understands that it has to do with a web page in that address. Is there
> a way to access it using for example “forensick/page.html” (i suppose
> the answer here is dns)?

Yes, the /etc/hosts file only provides address resolution for the
computer that it is on. It has no effect on any other computer. And as
you see, the /etc/hosts files on different computers can give quite
different answers to the same question.

I suggest you try to understand a bit more about DNS. There is a lot on
the web. You could search for an article you like, or you could start
with something like:

http://en.wikipedia.org/wiki/Domain_Name_System
http://www.howstuffworks.com/dns.htm

You need a DNS server. There are three ways I can think of that may be
sensible to try:

(1) Use the noip server. I think you have everything else you need
working now, so if you can make that work, you are done.

(2) If that’s too big a step, try to use your internet router. Many
routers offer DHCP and some include local DNS. If yours does, then you
could configure it to give names to your various PCs and change IP
addresses etc as you wish in order to learn more.

(3) As an alternative to reconfiguring your router, you could install
and configure a DNS server on an openSUSE computer. You could read about
this at

http://doc.opensuse.org/documentation/html/openSUSE/opensuse-reference/cha.dns.html

Djh-novell, thanks for the answer!

Sorry I was a little abstract there. I meant, that the final server wil be with a static ip address, but I don’t have the time right now to set it up as it will be(at the place which have the static ip). So I have to “play” with dynamic addresses(at home), although as I can understand it will be a little harder.

I thought that although the server will be at a single pc, it might be a good idea to be free of the pc ip lan address and have its own. Ofcourse as I can think of that right now, the main purpose is that a server has a single and only place in a lan. Maybe I was a bit confused by doing this at home, because all devices here are assigned a lan ip address dynamically.

I think I blurred the waters here when I referred to the no-ip web site. What I meant is:
Because I cant work from home with the specific domain that the server will be, to learn how to setup the apache server and got it working through the internet, the idea was to associate it with a free domain name, just to see the whole procedure.

So the server will be at home( with dynamic ip lan and wan address) and I want to connect it with a something.no-ip.biz address. So if you put in the address bar of your browser the something.no-ip.biz address, then you will be redirected to the page.html that will be on my apache server at home.

I am a bit familiar with the DNS technology in general (I mean just what is the job of that protocol),but I am surely missing the connecting point with the apache server. Ofcourse I’ll start reading right away the links you provided :slight_smile:

Oh, and something else. The final project will have the apache in a static ip address with its domain. The hosts that will have to connect with the server and send their data to it, they may have dymanic ip addresses, so when finishing this project from home (with all these dynamic addresse), I suppose it will easier to understand the changes. Or this is how I imagine it.

Thanks again for your time!

On 04/09/2013 05:36 AM, forensick wrote:
>
> Djh-novell, thanks for the answer!
> djh-novell;2545971 Wrote:
>> forensick wrote:
>>
>>> 2)After learning in some detail the lan procedures of apache, I then
>>> want to implement it in the internet. Because I don’t have the time
>>> (unfortunately) to go where the static ip address is, I thought that
>> it
>>> would be close to implement it using no-ip, which site will somehow
>> be
>>> connected to the pc with apache.
>>
>> You mean that your web server will be somewhere that you are not? (i.e.
>> probably hosted somewhere?) That’s not really a problem as long as you
>> have ssh access to it, or some equivalent. It is important to be able
>> to
>> access a client (browser) that is in a different place to the server on
>> the Internet, so as to check that DNS, and firewalls, and routing etc
>> are all working properly.
>
>
> Sorry I was a little abstract there. I meant, that the final server wil
> be with a static ip address, but I don’t have the time right now to
> set it up as it will be(at the place which have the static ip). So I
> have to “play” with dynamic addresses(at home), although as I can
> understand it will be a little harder.

A few random notes:

Just because you have dynamic IP address one one network normally does not
mean you are prevented from assigning an IP address statically/permanently
to a machine on that network. What happens then? The machine comes up,
binds its IP address, and generally things move along normally. Worst
case, the DHCP server has assigned, or will assign, the same IP to another
system. Sometimes things just work nicely, especially in home networks
where wireless is common, and sometimes one of the two machines will lose
connectivity. Often the DHCP service will detect the duplicate and hand
out something else, if the IP was assigned before DHCP gave it out.
Chances are good that you do not have 200+ machines at home, so just give
out a higher IP address that is unlikely to be given out via DHCP, or
configure DHCP to give out only part of the range (for my system that’s
0-10, since I will likely never have ten dynamic devices on my network at
home) and then the rest are available for you to assign statically.

Also, just to be as clear as possible, for your basic system Apache httpd
does not care, almost at all, about the IP address. Your /etc/hosts file
on the Apache httpd-running server is irrelevant and spending time
tweaking it is not getting you anywhere. All that matters, when it comes
to inter-machine communication, is that layers one, two, three, and four
all work (ignoring layer seven, as it’s irrelevant to this point). In
reverse order:
Layer 4 (TCP): Port (by default) 80 must be listening, unblocked, and
reachable via layer three.
Layer 3 (IP): The IP address, whatever it is, must get to the destination
box (Apache httpd server). This happens via layer two when on the same
network/segment.
Layer 2 (MAC/LLC): The switch/hub involved needs to be able to send the
encapsulated IP data to the right port, usually either by broadcasting
(hub) or by relying on the MAC address (switch). Connecting from the port
to the machine is handled by Layer one.
Layer 1 (physical): Wires must be connected.

Based on your description, all four layers work nicely since, at some
point, you are able to get to the server from a client. Hooray, and now
the next thing you are talking about is all about name resolution (DNS,
layer seven) and accessing the web service (HTTP, layer seven). The HTTP
part already works (the page loads when you specify the correct IP
address) so from there you are either back to using IP addresses directly
or using DNS, whose purpose is to get you an IP address indirectly. Pick
one, use it, move on. In your case for a test system it may be worthwhile
to just use an IP address, preferably a static IP address, but again
Apache httpd really does not care. Look in the httpd.conf or listen.conf
file (/etc/apache2 or somewhere under here) and look for a ‘Listen 80’
line. This basically states that httpd is configured to listen on port
80, but on all addresses, no matter what address is bound to the server.
As a result httpd does not care about the locally-bound address, or
whether it was static or dynamic. There are cases where the IP does
matter, but not in a case as basic as this one, so ignore it for now. You
can confirm that Apache httpd does not care about which IP address is
bound via the netstat command on the server side; chances are good you
will see it bound to 0.0.0.0 (all address) instead of 192.168.1.3 (your
machine’s specific address):

Code:

netstat -planet | grep :80

All you seem to have working is the ability to reliably access your server
from your clients. To do that you have two good choices, and countless
less-good choices (assuming you are able to access the IPs for this
network directly):

  1. Setup a static IP address for the server and refer to it directly.
  2. Setup a dynamic IP address for the server and find it to refer to it
    directly.

If/When you move to a remote site outside of your local network things
become more interesting, but not terrible if you are using a static IP
address on your home network. The various no-ip services are usually made
to work based on your gateway’s IP address being dynamic, which is not
related to whether or not the internal devices on your internal network
are static or dynamic, so do not confuse the two or you will cause
yourself a lot of needless frustration.

Let’s see where you go from here before typing too much more. To start
out, use static IPs and be sure you understand how access to that server
works, with or without some form of name resolution and then go from there.

Good luck.

forensick wrote:
> I think I blurred the waters here when I referred to the no-ip web
> site. What I meant is:
> Because I cant work from home with the specific domain that the server
> will be, to learn how to setup the apache server and got it working
> through the internet, the idea was to associate it with a free domain
> name, just to see the whole procedure.

I think you are at the point where you could set up your final system
now. You might have to solve a few small issues when you do it, but
nothing insuperable.

You might learn more by following your plan to build a test system. But
the danger is that you will learn a lot that is irrelevant and that may
confuse you. Only you know what method of learning suits you best.

Here’s my setup, maybe it’s of some help:

Configured static LAN IP XXX.XXX.XXX.100 on the server, nameservers 8.8.8.8, 8.8.4.4, gateway ROUTER LAN IP.
Forwarded port YYYYY to 80 on LAN IP XXX.XXX.XXX.100 on my router
Installed the LAMP server pattern.
Used Yast - Network services - HTTP server to make it start at boot, listen to 127.0.0.1, LAN IP, WAN IP from the router.

Now, if the user wants, the LAN machines can reach the webserver on http://XXX.XXX.XXX.100 , all can reach the webserver from http:///ROUTER_LAN_IP:YYYYY

Now, if you would use something like no-ip, dyndns, point the domainname to your WAN IP (the one your provider is giving you), the same applies, except that users don’t have to use IP’s, they can use http://bladiebladiebla.no-ip.net etc