Zen Cart Logo
Forums / Installing on a Linux/Unix Server / Works On The Server, No Where Else! (using small internal network LAN)

Works On The Server, No Where Else! (using small internal network LAN)

Locked

Views: 10,290

Results 1 to 16 of 16
This thread is locked. New replies are disabled.
29 Jun 2006, 4:40 PM
#1
merlot avatar

merlot

New Zenner

Join Date:
Jun 2006
Posts:
4
Plugin Contributions:
0

Works On The Server, No Where Else! (using small internal network LAN)

Completely bewildered by this behavior. Have done fresh install of zencart ( v1.3.0.2 full ) on RedHat Linux. Did the normal prelimary chmod adjustments prior, and after the install. Using irefox browser on the server with http://localhost looks great and the install is done so the Zencart index.php is in the web server's root directory. No warnings or error messages of any kind show on the storefront when accessing the store directly on the server. Thouht we were ready to start customizing.

However if I go to any other machine on the LAN and enter http://IPAddress it delivers the text only and no images, and any link selected delivers a 404.
Same problem occurs if we use http://mydomain.com that points to this server from the outside. Port 80 is open and if I place a sample index.html in place of the index.php and try to access it, it works fine.

RHEL:
MySQL 4.1.20,
Php 4.3.9,
Apache v2.0.52

I've also installed Zencart with RHEL and XAMPP and it replicates the problem exactly the same. Works fine on the server, fails everywhere else.

Hostname: estore

I've looked at the /admin/includes/configure.php and all four Define statements for HTTP_Server and HTTP_Catalog_Server all have http://localhost ( which is what I thought it should be ).

Its an understatement to say we missed something but we're completely perplexed!

Anybody seen anything like this?

merlot

29 Jun 2006, 7:23 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Works On The Server, No Where Else! (using small internal network LAN)

This is a typical problem for someone trying to work on a small network.

"localhost" always means "my computer" ... not necessarily the server.

Thus, while the server can see localhost as itself properly, Computer A will look for a webserver on Computer A when looking up "localhost", rather than the server.

You need to use the real IP address instead of localhost when you install Zen Cart, or manually edit the configure.php files to change http://localhost to http://192.168.0.1 or whatever the IP address is.

Don't touch the line for DATABASE_SERVER ... if it's localhost, it should STAY localhost.

29 Jun 2006, 8:24 PM
#3
merlot avatar

merlot

New Zenner

Join Date:
Jun 2006
Posts:
4
Plugin Contributions:
0

Re: Works On The Server, No Where Else! (using small internal network LAN)

OK.

We have two occurences of configure.php:

First:
/htdocs/includes/configure.php. Did a search on "localhost". There's only 1 occurence in line 71 in the 'DB_SERVER', 'localhost', but based on our read of the input we left this as is. Was that correct?

Second:
/htdocs/admin/includes/configure.php
Four occurences each in a define statement, lines 26-29
define('HTTP_SERVER', 'http://localhost'); we changed to 'http://192.168.1.193');
The next 3 lines were nearly identical.

We saved, rebooted and tested again. Ouch, same problem as before.

29 Jun 2006, 8:26 PM
#4
merlot avatar

merlot

New Zenner

Join Date:
Jun 2006
Posts:
4
Plugin Contributions:
0

Re: Works On The Server, No Where Else! (using small internal network LAN)

Just after hitting the send button we realized we looked at the configure.php's incorrectly. Will revisit that again and update.

Also, thanks for the previous input.

-Merlot

29 Jun 2006, 8:35 PM
#5
merlot avatar

merlot

New Zenner

Join Date:
Jun 2006
Posts:
4
Plugin Contributions:
0

Re: Works On The Server, No Where Else! (using small internal network LAN)

Success!

We missed one of the localhost entries. We really look forward to customizing this.

Thanks again

4 Jul 2006, 6:12 PM
#6
joelcap avatar

joelcap

New Zenner

Join Date:
May 2005
Posts:
4
Plugin Contributions:
0

Re: Works On The Server, No Where Else! (using small internal network LAN)

merlot:

OK.

We have two occurences of configure.php:

First:
/htdocs/includes/configure.php. Did a search on "localhost". There's only 1 occurence in line 71 in the 'DB_SERVER', 'localhost', but based on our read of the input we left this as is. Was that correct?

Second:
/htdocs/admin/includes/configure.php
Four occurences each in a define statement, lines 26-29
define('HTTP_SERVER', 'http://localhost'); we changed to 'http://192.168.1.193');
The next 3 lines were nearly identical.

We saved, rebooted and tested again. Ouch, same problem as before.

I notest that this changes are only made ind the admin zone store, and not on the shopping store. I made those changes and when I try to enter the adin zone from the zerver I cannot do it anymore. Now from the server I only access to the shopping cart.
Is this normal?

In any case I don't enter the admin zone either the shopping zone from a remote pc.

7 Jul 2006, 5:02 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Works On The Server, No Where Else! (using small internal network LAN)

If you have things configured properly, you should be able to access from both the server and other PC's

26 Dec 2006, 12:30 AM
#8
tonybergdahl avatar

tonybergdahl

New Zenner

Join Date:
Aug 2006
Location:
Upplands Väsby
Posts:
8
Plugin Contributions:
0

Re: Works On The Server, No Where Else! (using small internal network LAN)

I have the same problem. In configure.php i have my domainadress http://www.mysite.se when the site works outside LAN. When i take a look at the site inside LAN i only shows text becouse of wrong links. So i have to change to ../ or http://192.168.1.38. to se it normal. I have tryed everything but i cant find any easy solution. The best was just write ../ it worked fine internal and erxternal - fine! But when i tryed with IE it failed. Microsoft as usual.
/Tony

23 Apr 2007, 11:30 AM
#9
leifmoni avatar

leifmoni

New Zenner

Join Date:
Jan 2007
Posts:
6
Plugin Contributions:
0

Re: Works On The Server, No Where Else! (using small internal network LAN)

I have had this problem for 5 month now without finding a solution

23 Apr 2007, 11:34 AM
#10
leifmoni avatar

leifmoni

New Zenner

Join Date:
Jan 2007
Posts:
6
Plugin Contributions:
0

Re: Works On The Server, No Where Else! (using small internal network LAN)

leifmoni:

I have had this problem for 5 month now without finding a solution
But it also occure with JOOMLA! and osCommerce - works on server and on LAN but not from outside the Internet ??

Still searching...:yuck:

23 Apr 2007, 11:48 AM
#11
leifmoni avatar

leifmoni

New Zenner

Join Date:
Jan 2007
Posts:
6
Plugin Contributions:
0

Re: Works On The Server, No Where Else! (using small internal network LAN)

I have had this problem for 5 month now without finding a solution
And I think that is have to do with the PHP.INI file - [MySQL] section
What helped me to make it look nice on my other LAN PC was adding this code to the
top of my zencart configure.php file located in .. /catalog/includes

$domain = "***********"; //initialization of the string (168.192.1.5 have 11chars)
$host_ip = gethostbyname($domain);
$user_ip = getenv("REMOTE_ADDR"); //get the remote user ip

if ($user_ip = '192.168.1.5') //a PC on my LAN
{
define('HTTP_SERVER', 'http://192.168.1.2'); //PC with the webserver on my LAN
define('HTTPS_SERVER', 'http://192.168.1.2');//
}
else
{
define('HTTP_SERVER', 'http://kapacitetsregnskabet.dk' . $host_ip); //
define('HTTPS_SERVER', 'http://kapacitetsregnskabet.dk' . $host_ip);//
}

30 Apr 2007, 2:52 PM
#12
leifmoni avatar

leifmoni

New Zenner

Join Date:
Jan 2007
Posts:
6
Plugin Contributions:
0

Re: Works On The Server, No Where Else! (using small internal network LAN)

Now it works both on my LAN and from outside the Internet.
My problem was that lag of knowledge about PHP

  1. the string should be initiated by my domain name kapacitetsregnskabet.dk
    and not 11 *'s:clap:
  2. the boolean 'equal to' is a double equal sign == and not a single one
    a single one will just initiate the string with that value

Here is the code snippet which I place in the configure.php file

It can be made smarter

/////////////////////////////////////////////////////////////////
$domain = "kapacitetsregnskabet.dk";
$host_ip = gethostbyname($domain);
$user_ip = getenv("REMOTE_ADDR");

if($user_ip == '192.168.1.5')
{
define('HTTP_SERVER', 'http://192.168.1.2');
}
else
{
if($user_ip == '192.168.1.2')
{
define('HTTP_SERVER', 'http://192.168.1.2');
}
else
{
define('HTTP_SERVER', 'http://kapacitetsregnskabet.dk');
define('HTTPS_SERVER','https://kapacitetsregnskabet.dk');
}
}
//////////////////////////////////////////////////////////////////

16 May 2007, 11:13 AM
#13
guin avatar

guin

New Zenner

Join Date:
May 2007
Posts:
1
Plugin Contributions:
0

Re: Works On The Server, No Where Else! (using small internal network LAN)

leifmoni:

But it also occure with JOOMLA! and osCommerce - works on server and on LAN but not from outside the Internet ??

Still searching...:yuck:

I set this up yesterday and was having exactly the same problem - several searches later still no dice. I tried the above suggestion of removing all reverences of http://localhost from the configuration.php file and changing it to http://[hostipaddress] - hey presto it worked. In Joomla it was the configuration.php file and I only had to change one occurrance.

As posted by Dr Byte this is what I did

DrByte:

This is a typical problem for someone trying to work on a small network.

"localhost" always means "my computer" ... not necessarily the server.

Thus, while the server can see localhost as itself properly, Computer A will look for a webserver on Computer A when looking up "localhost", rather than the server.

You need to use the real IP address instead of localhost when you install Zen Cart, or manually edit the configure.php files to change http://localhost to http://192.168.0.1 or whatever the IP address is.

Don't touch the line for DATABASE_SERVER ... if it's localhost, it should STAY localhost.

Thanks for the tips a real help :clap:

20 May 2007, 8:53 PM
#14
tonybergdahl avatar

tonybergdahl

New Zenner

Join Date:
Aug 2006
Location:
Upplands Väsby
Posts:
8
Plugin Contributions:
0

Re: Works On The Server, No Where Else! (using small internal network LAN)

leifmoni:

Now it works both on my LAN and from outside the Internet.
My problem was that lag of knowledge about PHP

  1. the string should be initiated by my domain name kapacitetsregnskabet.dk
    and not 11 *'s:clap:
  2. the boolean 'equal to' is a double equal sign == and not a single one
    a single one will just initiate the string with that value

Here is the code snippet which I place in the configure.php file

It can be made smarter

/////////////////////////////////////////////////////////////////
$domain = "kapacitetsregnskabet.dk";
$host_ip = gethostbyname($domain);
$user_ip = getenv("REMOTE_ADDR");

if($user_ip == '192.168.1.5')
{
define('HTTP_SERVER', 'http://192.168.1.2');
}
else
{
if($user_ip == '192.168.1.2')
{
define('HTTP_SERVER', 'http://192.168.1.2');
}
else
{
define('HTTP_SERVER', 'http://kapacitetsregnskabet.dk');
define('HTTPS_SERVER','https://kapacitetsregnskabet.dk');
}
}
//////////////////////////////////////////////////////////////////

Dear sirs,
I tried this script but without success. Can you please explain a bit more hot to get this to work.

20 May 2007, 9:43 PM
#15
chuckl avatar

chuckl

Totally Zenned

Join Date:
Nov 2006
Location:
Papworth, Cambridgeshire, UK
Posts:
717
Plugin Contributions:
0

Re: Works On The Server, No Where Else! (using small internal network LAN)

There are several ways to solve this, some easier than others, some more likely to cause problems than others.
A typical scenario is that you have an internet broadband connection, ending in a router at your premises, with a fixed IP address. The router is set to pass some or all incoming traffic to a designated machine or machines, often called DMZ machine/s.
If we take a webserver as an example - you have a registered domain - https://www.mydomain.com, and a DNS nameserver somewhere has a record that points that domain to the external fixed IP address of your router. The router then forwards any incoming port 80 or whatever web traffic to your DMZ web server, which is set up lets say as https://www.mydomain.com IP 192.168.0.100, and it all works.
So anyone on the wider internet can access your site quite happily.

However, on your small internal network you use non routable IP addresses, 192.168.0.X or similar, and your web server in fact has one of these addresses. It only gets the internet traffic because the router is translating from the external internet IP address and forwarding the traffic to the correct 'internal' non routable address of the web server.
All your other machines on your LAN, if they query the nameserver will be given the external IP address of your router, which is no help, as you are already 'inside' in the non routable section.
The simplest solution for this is to edit the hosts file on each of you internal LAN machines, and add an entry - 192.168.0.100 https://www.mydomain.com

On Windows machines the hosts file is usually
C:\WindowsDirectory\system32\drivers\etc\hosts - e.g. C:\windows\system32\drivers\etc\hosts
and on Linux or Unix machines - /etc/hosts
It is a plain text file, but be very careful when editing on Windows machines, since both Notepad and Wordpad love putting a .txt extension on the file, which breaks everything. Command line edit works (shudder).

Now when you enter https://www.mydomain.com in a browser, your machine checks the hosts file, finds the entry, and uses that address. Note that 'localhost' on the server is an absolute nono except for the database, for the reasons Dr.Byte mentioned in an earlier post.

Other possible solutions are
To set up a LAN nameserver with an internal zone, and you can have hours, days and weeks of harmless fun getting that to work.
Set up a proxy server for the internet and your web server, and route all your internal web traffic through it - more hours etc etc.
Set up an additional domain name record on your external DNS with an entry for your internal non routable IP. This works very well for the internal machines, but is Extremely frowned upon by people with enough money and equipment to have lots of routers and IP addresses and the like. It also causes many services like website validation etc to choke. (Rulebook says you are not allowed to have non routable IP's on the internet)

Stick with the hosts file.

21 May 2007, 8:30 AM
#16
leifmoni avatar

leifmoni

New Zenner

Join Date:
Jan 2007
Posts:
6
Plugin Contributions:
0

Re: Works On The Server, No Where Else! (using small internal network LAN)

Sorry this was not a script but some code inserted into the ../catalog/includes/config.php file
My whole config.php file is here:

<?php /** * * @package Configuration Settings * @copyright Copyright 2003-2006 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 */ /*************** NOTE: This file is similar, but DIFFERENT from the "admin" version of configure.php. ***********/ /*************** The 2 files should be kept separate and not used to overwrite each other. ***********/ // Define the webserver and path parameters // HTTP_SERVER is your Main webserver: eg, <http://www.yourdomain.com> // HTTPS_SERVER is your Secure webserver: eg, <https://www.yourdomain.com> // Use secure webserver for checkout procedure? define('ENABLE_SSL', 'false'); // NOTE: be sure to leave the trailing '/' at the end of these lines if you make changes! // * DIR_WS_* = Webserver directories (virtual/URL) // these paths are relative to top of your webspace (ie: under the public_html or httpdocs folder) ///////////////////////////////////////////////////////////////// $domain = "kapacitetsregnskabet.dk"; // 80.63.232.121 $host_ip = gethostbyname($domain); $user_ip = getenv("REMOTE_ADDR"); if($user_ip == '192.168.1.5') { define('HTTP_SERVER', 'http://192.168.1.2'); } else { if($user_ip == '192.168.1.2') { define('HTTP_SERVER', 'http://192.168.1.2'); } else { define('HTTP_SERVER', 'http://kapacitetsregnskabet.dk'); // define('HTTPS_SERVER','https://kapacitetsregnskabet.dk');// } } ////////////////////////////////////////////////////////////////// //define('HTTP_SERVER', 'http://kapacitetsregnskabet.dk'); // //define('HTTPS_SERVER','https://kapacitetsregnskabet.dk');// define('DIR_WS_CATALOG', '/catalog/'); //kun text hvis denne ændres !! define('DIR_WS_HTTPS_CATALOG', '/catalog/'); define('DIR_WS_IMAGES', 'images/'); define('DIR_WS_INCLUDES', 'includes/'); define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/'); define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/'); define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/'); define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/'); define('DIR_WS_DOWNLOAD_PUBLIC', DIR_WS_CATALOG . 'pub/'); define('DIR_WS_TEMPLATES', DIR_WS_INCLUDES . 'templates/'); define('DIR_WS_PHPBB', '/'); // * DIR_FS_* = Filesystem directories (local/physical) //the following path is a COMPLETE path to your Zen Cart files. eg: /var/www/vhost/accountname/public_html/store/ define('DIR_FS_CATALOG', 'D:/webs/test/Catalog/'); define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/'); define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/'); define('DIR_WS_UPLOADS', DIR_WS_IMAGES . 'uploads/'); define('DIR_FS_UPLOADS', DIR_FS_CATALOG . DIR_WS_UPLOADS); define('DIR_FS_EMAIL_TEMPLATES', DIR_FS_CATALOG . 'email/'); // define our database connection define('DB_TYPE', 'mysql'); define('DB_PREFIX', 'zen_'); define('DB_SERVER', 'localhost'); define('DB_SERVER_USERNAME', 'root'); define('DB_SERVER_PASSWORD', ''); define('DB_DATABASE', 'zencart'); define('USE_PCONNECT', 'false'); // use persistent connections? define('STORE_SESSIONS', 'db'); // use 'db' for best support, or '' for file-based storage // The next 2 "defines" are for SQL cache support. // For SQL_CACHE_METHOD, you can select from: none, database, or file // If you choose "file", then you need to set the DIR_FS_SQL_CACHE to a directory where your apache // or webserver user has write privileges (chmod 666 or 777). We recommend using the "cache" folder inside the Zen Cart folder // ie: /path/to/your/webspace/public_html/zen/cache -- leave no trailing slash define('SQL_CACHE_METHOD', 'none'); define('DIR_FS_SQL_CACHE', 'D:/webs/test/Catalog/cache'); ?>

If You want to admin from outside the Internet You have to change the ../catalog/admin/includes/configure.php as well

Sincerely

Leif Mønnike