LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Apache 2 lan & internet (https://www.linuxquestions.org/questions/linux-software-2/apache-2-lan-and-internet-299064/)

JJX 03-08-2005 06:37 AM

Apache 2 lan & internet
 
I want apache2 serve the same pages to my lan and to internet
My config:

Code:

NameVirtualHost 10.19.146.161:80
................................
<VirtualHost 10.19.146.161:80>
    ServerAdmin root@localhost
    DocumentRoot /var/www/mysite
    ServerName mysite.com
    ErrorLog /var/log/apache2/mysite.log
</VirtualHost>
.................................
<VirtualHost *:80>
    ServerAdmin root@localhost
    DocumentRoot /var/www/mysite
    ServerName mysite.homeip.net
    ErrorLog /var/log/apache2/mysite_inet.log
</VirtualHost>

Mysite on lan works fine
When i try to access the site from internet i see apache2's default page.
However, i can access the site using mysite.homeip.net/mysite and i am facing some problems (page not found problems - work perfecy on lan)

Do i have to define a new NameVirtualHost ? (my ip is dynamic)
I dont have any firewall (closed until i get it working), and NAT/PAT seems to work (i get the default).

Artanicus 03-08-2005 09:03 AM

Now, firstly I dont understand why do you have to use virtual hosts for your situation at all.. But im gona ssume you have a good reason for it.

I just figured a few hours ago how the virtualhosts actually work.. So, basing on that, id suggest you try out this virtualHost config:
Code:

NameVirtualHost *:80

# LAN
<VirtualHost *:80>
DocumentRoot /var/www/mysite
ServerName mysite.com # a LAN domain pointer
</VirtualHost>

# PUBLIC
<VirtualHost *:80>
    DocumentRoot /var/www/mysite
    ServerName mysite.homeip.net # a public domain for your site
ServerAlias *.mysite.homeip.net # you prolly dont need this, my subdomains do..
</VirtualHost>

I dont guarantee itll work, but worth a try..

hanzerik 03-08-2005 09:06 AM

Is there a reason you are using Virtual hosts? No need to if all you want to do is serve the same pages/site for both LAN and WAN.


Check out http://www.no-ip.com, they have a program to automatically check for changes in your assigned IP, and when it detects a change it will update the dns records.

@ngelot 03-09-2005 05:53 PM

I've got some of the same problem:

I can't get this to work:

I'm trying to get me1.homeftp.org to point to /var/www/ and me2.shacknet.nu to /var/www/me2/

Code:

NameVirtualHost me1.homeftp.org
NameVirtualHost me2.shacknet.nu

<VirtualHost me1.homeftp.org>
    ServerAdmin admin@me1.homeftp.org
    DocumentRoot /var/www/
    ServerName me1.homeftp.org
</VirtualHost>

<VirtualHost me2.shacknet.nu>
    ServerAdmin admin@me1.homeftp.org
    DocumentRoot /var/www/me2
    ServerName me2.shacknet.nu
</VirtualHost>

For both me1.homeftp.org and me2.shacknet.nu I get to /var/www, but I want me2.shacknet.nu to point to /var/www/me2

What am I doing wrong?

Artanicus 03-10-2005 05:46 AM

Quote:

Originally posted by @ngelot
I've got some of the same problem:

I can't get this to work:

I'm trying to get me1.homeftp.org to point to /var/www/ and me2.shacknet.nu to /var/www/me2/

Code:

NameVirtualHost me1.homeftp.org
NameVirtualHost me2.shacknet.nu

<VirtualHost me1.homeftp.org>
    ServerAdmin admin@me1.homeftp.org
    DocumentRoot /var/www/
    ServerName me1.homeftp.org
</VirtualHost>

<VirtualHost me2.shacknet.nu>
    ServerAdmin admin@me1.homeftp.org
    DocumentRoot /var/www/me2
    ServerName me2.shacknet.nu
</VirtualHost>

For both me1.homeftp.org and me2.shacknet.nu I get to /var/www, but I want me2.shacknet.nu to point to /var/www/me2

What am I doing wrong?

If you start your httpd with the parameter S, what does it tell you?
Code:

httpd -S
Its a switch to closely evaluate the virtual hosts config..

JJX 03-10-2005 07:09 AM

httpd -doesnt exist anymore (or at least debian distro)

try: apache2ctl -S


Also change
NameVirtualHost me1.homeftp.org
NameVirtualHost <IP>

<IP>= ip of the interface where gets the inet (eth to router or something like that)


All times are GMT -5. The time now is 01:17 AM.