Dashboard wan - lan url

Problem:

My webserver is behind a firewall/router and therefor it has an lan ip adr. (192.168.1.240 ex.), i also have a publich ip adr.

and forwarded the ports (works)

But the dashboard grab the local ip adr. 

So is there any place to change the path/ip adr. so it will use the publich adr.?

lan - wan ip adr.

Larsjo's picture

Re: Dashboard wan - lan url

No One with any input on this problem?

 

I even tried with some nat settings in my firewall, with no luck

TrystanLea's picture

Re: Dashboard wan - lan url

Hello Larsjo, sorry for a slow reply on this, it might be possible to manually enter the path at the top of emoncms/Modules/dashboard/Views/dashboard_view.php? but it is / or is it strange that all the other javascript libraries load fine?

try setting $path = "http://YOURIPADDRESS/emoncms/";

gyebi's picture

Re: Dashboard wan - lan url

Hi,

Unfortunately i have the same problem with my PI;

I put the behind a Public router:I forwarded the Pi port to the public ip:888

But No graph on the dashboards and the the symptom is the same.

I tried to fix with the within the php code to $path = "http://YOURIPADDRESS/emoncms/";

but no effect;

I've tried to debug the problem within the generated html code:

there is a code within the "dashboard_view.php" wich  - i think  - which will generate the private addresses for the graphs:

<div id="page"><?php echo $dashboard['content']; ?></div>

I hardcoded the Public URL to the "dashboard_view.php" - instead of the generated one:the graph is magicaly showed up;

Somebody have any clue how to fix this?

Regards, Krisztian

jend's picture

Re: Dashboard wan - lan url

Have you had any success resolving the issue?  I have a similar problem with Emoncms behind a firewall.  Initially I built a CentOS based Emoncms server on my LAN and this worked perfectly.  I then moved my server to my DMZ so I could get data sent from a remote site.  When I came to access any of the Emoncms from my LAN to DMZ the web interface was extremely slow, often timing out before displaying the page.  I have SELINUX and the CentOS firewall disabled.  The default Apache web page on the root of the web server works fine.  As do other services from LAN to DMZ, eg ssh.

I have recently moved the server back into the LAN and opened a pin hole to port 80 on the server.  When I access Emoncms from my remote location I get the same symptoms, ie slow response often resulting in a timeout.  Interestingly though  sending readings from the remote location works fine.  To do this I am using:

http://server/emoncms/input/post?time=xxxxxxxxx&json={Meter:1.23}&apikey=abcdef

Not really sure if this a  networking issue or Emoncms issue.  I'm using the commercial firewall Astaro with a home users license so it not like it’s a cheap ADSL router.  Does anyone one have any ideas?

 

Cheers, Jason

jonbev's picture

Re: Dashboard wan - lan url

I had a similar issue with my Pi the Iframe on the dashboard references the internal IP. I have found a work around and that is to edit the content field in the database so that the iframe src is relative rather than the fully qualified path.

vfnewman's picture

Re: Dashboard wan - lan url

jonbev,

 

Can you please give us some directions on where to edit the database and how to change the link to relative?  I'm running my own server on a Raspberry Pi and this problem prevents any of the graphs from appearing when accessed from outside my home network.

Thank you very much in advance.

 

Victor Newman 

jonbev's picture

Re: Dashboard wan - lan url

If you are familiar with MySQL you just need to run this update statement -

update dashboard set content=replace(content, 'src="http://192.168.1.76/emoncms/', 'src="/emoncms/');

Just change the local ip for your own.

 

If you need more instruction on MySQL just let me know.

Jon

vfnewman's picture

Re: Dashboard wan - lan url

Jon,

I'm only minimally familiar with *nix and effectively not at all with MySQL.  I understand what this fix does, and I know how to work from a command prompt, but what I'm not sure of is where/how I run it, so yes, I would be infinitely appreciative of some hand-holding (figuratively speaking, of course) here.

Thank you very much,

Victor Newman 

jonbev's picture

Re: Dashboard wan - lan url

OK no problem.

Log into command line and run mysql with this command "mysql -uroot -p emoncms" then enter password.

You should get a mysql> prompt. Enter the update statement here.

update dashboard set content=replace(content, 'src="http://192.168.1.76/emoncms/', 'src="/emoncms/');

You should get the following response -

Query OK, 1 rows affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

Then type exit to leave mysql.

vfnewman's picture

Re: Dashboard wan - lan url

Jon,

Thank you very much for the help.  I ran into problems.

>Log into command line and run mysql with this command "mysql -uroot -p emoncms" then enter password.

I did, and that worked, but it never asked me for a password.

>You should get a mysql> prompt. Enter the update statement here.

>update dashboard set content=replace(content, 'src="http://192.168.1.76/emoncms/', 'src="/emoncms/');

 

I did that, and it returned an error saying I was in the wrong database.  I tried entering "use emoncms" and it gave me an error there too.

Any ideas?

Thank you very much for your help.

Victor Newman 

 

 

 

jonbev's picture

Re: Dashboard wan - lan url

I guess your database has a different name. Check the name in the settings.php file and use that. Mine shows -

  $username = "root";
  $password = "password";
  $server   = "localhost";
  $database = "emoncms";

 

Jon

vfnewman's picture

Re: Dashboard wan - lan url

I get exactly the same thing:

 

$username = "root";
  $password = "mypassword";
  $server   = "localhost";
  $database = "emoncms";

:-/

 

Victor Newman 

TrystanLea's picture

Re: Dashboard wan - lan url

I wonder if this will do it, the absolute path is set on line 22 of index.php

$path = get_application_path();

would it work to change that to:

$path = "http://EXTERNALIP/emoncms/";

Pretty much all css, js and menu links uses the $path variable. You may need to refresh the iframes in the dashboard to change over to the new path for it to work for them.

Trystan

vfnewman's picture

Re: Dashboard wan - lan url

Update: Success!

I had originally tried following your instructions working from the desktop of the pi.  This time I tried it through Putty.  It worked.

Thank you very, very much for your patient assistance.

Victor Newman 

jonbev's picture

Re: Dashboard wan - lan url

Trystan - is there a need for it to be absolute can't they all be relative?

Victor - Glad I could help.

o_cee's picture

Re: Dashboard wan - lan url

Exactly, all paths need to be relative instead of absolute. Using on two different IPs will most likely be very common once people start using Raspberries as their primary server.

There shouldn't be any downsides to this at all, will be testing it now.

Edit: Another case where absolute URLs are a bad idea is if the server doesn't have a fixed IP/DNS, or if you decide to change IPs for some reason. That would break all your dashboards.

o_cee's picture

Re: Dashboard wan - lan url

Have been running with $path = '/'; since yesterday without any problems.

kieranc's picture

Re: Dashboard wan - lan url

When I set up my EmonCMS the first time I encountered this problem and having just set it up again 6 months later I'm disappointed to find I had the same problem. Is there somewhere I can report this as a bug, and can anyone point me towards whichever file creates this problem in the first place IE puts the internal IP address into the database?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.