Accesing localhost via IP from another device Ubuntu [closed]

Accesing localhost via IP from another device Ubuntu [closed]



I'm running localhost server on Ubuntu with xampp.
I want to access that server from another device within the same network.
To achieve that i'm using host IP adress from local network which is 192.168.150.250.


192.168.150.250



When i'm entering 192.168.150.250 from another device than localhost content is loaded and now i can see the xampp dashboard. When i'm trying to get into subdirectory of host. E.g 192.168.150.250/my-site url is instantly redirected into localhost/my-site.


192.168.150.250


192.168.150.250/my-site


localhost/my-site



What's strange not all the devices are redirected. For example my iOS device is not changing IP adress for localhost but my laptop does. I thought it may be caused by firewall so i disable it using :
sudo ufw disable
Now it's getting very interesting because this setting enabled my laptop Explorer browser to connect with my host, but in the same laptop Chrome browser is still redirecting site from IP to localhost.


sudo ufw disable



My etc/hosts file


127.0.0.1 localhost
127.0.1.1 Ubuntu-X

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters



What can cause this strange redirects? Why it's working on some devices and browsers when it doesn't on others?



Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.




3 Answers
3



When a web server is processing dynamically-generated pages and needs to generate a fully-qualified URL that refers back to itself, it needs to know what to put into the hostname/address part of the URL.



If there is nothing more specific defined, the default is usually "localhost" because it's the safe choice, and it works for quick test setups that are intended to be accessible only locally.



When you need the server to be accessible from other devices too, the "proper" way to do it would be to make sure the server has a name that is resolvable by the other devices, and then use that name in ServerName directive in the main server and/or VirtualHost parts of your Apache configuration.


ServerName



An alternative solution would be to set UseCanonicalName Off in Apache configuration: when you do that, Apache will create self-referential URLs dynamically by using whatever name or IP address the client used to reach the server in the first place.


UseCanonicalName Off



The URL generation may also be happening within a PHP- or Perl-based web application; in that case, the application probably has its own configuration settings for that.



Problem solved.



The issue here was my browsers and their cached files. After cleaning cache or going strictly to private browsing mode - page is displayed correctly.



my-site is doing this redirection...



Maybe because something at the source code of my-site, that is configured to use localhost or because a .htaccess inside my-site.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)