I've installed an Apache to my xBian and I've a web interface to my raspi. I'm using dynamically generated galleries for my pictures on it so the website can be pretty bulky in terms of traffic.

I've noticed that the system is going more or less at the same speed from my LAN than from the internet. Is there a way to force browser/apache to communicate using the LAN when available (improving the speed)?

  • Wouldn't this depend on who is connecting to it? I'm not sure you're making the problem very clear.
    – Jivings
    Feb 10 '14 at 8:53
  • I have the system working at home. I have a dynamic dns so I used one of those dynamicdns domains and an script that updates my public address to it. Then I access the webpage using this public domain that points to my public address. I access the webpage using this public domain (cacharro.ole32.com) always (I have it in bookmarks) and Id like the system to identify if I'm connecting from the internet or from the LAN and use the fastest way to provide the response.
    – javirs
    Feb 10 '14 at 8:58
  • If the user is connecting via LAN on an internal IP, it will respond via the LAN. If the user is connecting on an external IP there's no way to derive an internal IP from it.
    – Jivings
    Feb 10 '14 at 8:59
  • so, I need to have two bookmarks for the system (192.168.x.y and cacharro.ole32.com) and use one or the other depending on where I am ?
    – javirs
    Feb 10 '14 at 8:59
  • Or just always use the public IP, you said there was no difference in terms of speed.
    – Jivings
    Feb 10 '14 at 17:30

Do a mod_rewrite on the source IP of requests and redirect to the LAN IP.

If you are connecting to your own public IP, the source IP should either be your own public IP or the IP of your gateway.

You could also write a small PHP script which does the redirection (example: /redir.php) and bookmark that instead.

  • Im more interested in the php version, since I already have something similar for mobile - laptop redirecting. How can I check if the connecting device is in the LAN or not ??
    – javirs
    Feb 17 '14 at 10:38
  • For starters: Create a script which just returns the remote address of the client <?PHP echo($_SERVER['REMOTE_ADDR']); ?>. If you are connecting to the server from an internal client, the IP should be an internal IP or the external IP of your router (depending on your network configuration). Do a check on the IP address, to determine if it is an inside/outside client and redirect accordingly (use 302 to do a temp redirect)
    – Jervelund
    Feb 17 '14 at 22:35
  • Love it. I really thing that's a goood thing to do when you have your raspi as a server at home. I don't understand the downvotes in the question ...
    – javirs
    Feb 18 '14 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.