How to access a localhost website from another computer? - html

I am building my own website and I want to show my brother on the same network. But localhost is only on my computer... I think at least. Is there a way I ca nhost it on the network instead of my computer?

To access your localhost site from another computer, you can use the IP address of the computer on your local network where the site is located (for example: http://192.168.0.2/) instead of http://localhost/ or http://127.0.0.1/ which is the same thing.
If you are unable to do this due to a 404 or 403 error, check your web server configuration and/or firewall configuration.

Related

How can I share the output of an html code written in visual studio code with someone else?

I don't think that we can share the link that we get from the live server extension to someone else for viewing our web page.
kindly advise me. I am new to front-end development.
By default LiveServer will listen for network connections on 127.0.0.1 and is available only to clients running on the same computer.
You can change that in the settings (under Live Server > Settings:Host) to specify any IP address allocated to the computer you are working on. You can also use 0.0.0.0 for every IP address allocated to that computer.
Anyone who can reach the IP address you select (which is typically anyone on the same LAN as you) can then visit http://192.0.0.10:5500/ to see the site. (Replace the IP address in that example with the one assigned to your computer that you selected above).
For someone to access the server from a different network, you will need to have an IP address on the public Internet. Typically you would get this by following the above instructions and then configuring your router to forward port 5500 from its Internet facing IP address to the IP address of your computer on the LAN.
You can also look at tunnelling a connection with by creating an SSH tunnel manually or using a service like ngrok which connects a URL on the public Internet to your local server (note that this removes the requirement to change the Live Server configuration away from 127.0.0.1).

Browser tries to upgrade to HTTPS when accessing hosted server (dumb netcat binding) through domain name, but allows HTTP when using direct IP

I recently set up a Digital Ocean droplet and purchased a domain name. I have set up the AAAA record to point to the digital ocean droplet and have verified that the changes have propagated (for example, I can ssh to the server using the DNS name).
There is NO load balancer or firewall set up. The only digital ocean product I have set up is my droplet.
I noticed some bizarre behavior when running some tests.
I have tried several methods of serving HTTP content from the droplet, such as my personal site running in dotnet core and an express.js site.
However for this question I want to focus on the most basic example, to avoid the possibility that the request is being upgraded by a misconfigured server:
nc -l -p 1500 -c 'echo -e "HTTP/1.1 200 OK\n\n HELLO"'
When I navigate to the my droplet through my domain name (http://example.com:1500) , I see the netcat process finish executing in my droplet ssh session, and Chrome tells me:
This site can’t provide a secure connection. example.com sent an invalid response. ERR_SSL_PROTOCOL_ERROR.
I then see that the URL has somehow automatically changed to https//example.com:1500.
When I navigate to the droplet using the IP address (assuming my droplet IP is 12.34.56.78, I go to http://12.34.56.78:1500), I get the expected text "HELLO" displayed in the browser.
This result is the same in all browsers.
Why does making http requests to my droplet attempt upgrading to https, but only when going through the domain? Is this a browser behavior or something to do with Digital Ocean?
Thanks for taking the time to check out this question.
Figured it out. I have a .dev tld and chrome automatically upgrades all .dev tlds to HTTPS!
https://ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hsts/
This was driving me crazy.

hotlink working locally, not in server

I want to hotlink an image from a remote website. This works when I test in my local PC (Apache server), but doesn't work when I try from my website.
I am not an expert in this subject, but as I understand if hot-linking was blocked in the remote site, it should not work in my local server as well, right? In that case what might be the issue (my hosting provider is saying they don't have any issue)?
Let's play this through.
On your local server:
You make a request to 127.0.0.1 (or localhost) that returns some HTML with a hotlinked image to example.com.
The browser makes a subsequent request to example.com and sets the referer header to 127.0.0.1.
Now example.com has to determine whether the referrer is allowed to hotlink or not.
Since, for that server, example.com and 127.0.0.1 both refer to the same thing, namely the server itself, this looks like a valid request.
On your remote server:
Same as above, but replace 127.0.0.1 with your.favourite.url.
This time when the server validates the referrer, it will come to the conclusion that your.favourite.url and example.com do not refer to the same thing, and therefore block the image request.
This could be seen as a misconfiguration of example.com, since the referrer might not resolve to the same point from both client and server context.
If you access your local server via your local network IP (e.g. 192.168.1.42), then hotlinking should no longer work, unless example.com has a really graceful referrer policy, or happens to use exactly the same local IP as you.
It could also be possible to expose example.com's local IP by brute-forcing all local network IPs, though while that technically is an information leak, there's not much you can do with it.

Connect a website on hosting server to my localhost phpmysql

Just wandering if I can host my database locally for the website that is hosted on hosting provider's server. It means,
The web pages to be stored on hosting server.
The database to be stored on localhost (phpMySql).
In summary, How can I point my website to use the localhost database?
As #Eggplant sais in his comment, you can set your php to use "remote server" and link it to your localhost.
For example see this tutorial how to link it:
http://www.danielmois.com/article/Manage_remote_databases_from_localhost_with_phpMyAdmin
But your localhost should have public IP address and should be always online for your website to work correctly.
Not a good idea, IMHO

Localhost database connect from other sysytem

I am testing a website which in other machine like 192.168.0.1 in my machine which is 127.168.0.2 so in the website ajax jquery is used on page load in which the url is
http://localhost/Demo/store.php
but when i execute that page in website in other machine the database isnt connecting and even if i give the url as
http://192.168.0.1/Demo/store.php
its not connecting to database..What is the issue please tell me...How can i access from other system so that all my local database values can be displayed in other machines also..Thanx..
From http://technet.microsoft.com/en-us/library/cc940018.aspx:
address 127 .x.y.z is reserved for loopback testing and interprocess communication on the local computer.
Your probably not connected to your network correctly. Check your physical connection (blinking leds), then make sure you have a DHCP server on the network, otherwise assign a static IP.
After this try pinging the address to make sure the 2 hosts can see each other. Also open up any ports which may be behind a firewall, 3306 is default for MySQL DB.