I was reading about port forwarding which got me excited to try it myself.
But I'm stuck on the first step, given an html file how can I deploy it on my laptop's private ip address with custom port?
For example, imagine my laptop's ip is 10.0.0.4
Then when typing: 10.0.0.4:9011 in the browser I want to see the contents of the file.
Port forwarding would only be necessary if you want to make your laptop/server accessible outer your home network.
It is not only about port forwarding, you also need to install and run a server service like apache if you want to open that html file in a browser.
Additionally your laptop's public IP is probably not static. Almost all internet providers give you a dynamic IP for personal use. Which means that you need to use a different IP everyday to access that file.
However if you want to use that file only in your home network, then you still need a service like apache to host your file but you dont need a port forwarding + you can make your local IP static.
Here is a useful blog to host a website on your pc
Related
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).
I created successfully a apache server but I dont want to connect to it by typing 192.168.0.102, I want a normal url like www.google.com. How can I do that? I went to httpd.conf and found the ServerName line but setting it to something like www.mysite.com doesnt seem to work. I also tried to use my external ip(https://www.whatismyip.com) as server name but it doesnt connect. It only works if I try to connect to 192.168.0.102 or localhost. How do i solve this? Thanks
There are three basic things you need to know.
Virtual name hosting
HTTP allows multiple websites to be hosted on the same IP address and port. The client uses the Host request header to tell the server which site it wants to get data for.
ServerName is used as part of this.
… but the client needs to know how to send a request to the server first.
DNS
When a client makes a request to a server, it uses the IP address of the server in order to allow it to be passed over the network (or networks) to it. It is the address.
IP addresses are sequence so of numbers, which aren't very friendly for humans to work with.
DNS translates friendly names (like www.example.com) into IP addresses.
The client has to look up the name to find the IP address. It normally does this through the main DNS system, and in order to get your name linked to your IP address you will need to find a domain name registrar and pay them.
It is also possible to set up DNS at a local level on a private network, and on a computer-by-computer level using a hosts file.
Routing
The IP address of the server has to be routable from the computer the client is running on.
192.168.0.102 is a private address, accessibly only on the same LAN. To make it accessible to clients on the Internet you need to either:
Set up your router to use port forwarding and then use the Internet facing IP address of the router (which https://www.whatismyip.com tells you) or
Give your computer a public IP address and configure your router to route traffic to it (this generally isn't possible on consumer grade routers).
In short, you can't. 192.168.0.102 is not accessible from the Internet it is internal IP.
But you have some alternatives, like if you like to access your computer from a hostname you can use dynamic DNS servers.
Or you want to test your code on a spectacular domain, you can add 192.168.0.102 with a domain to your hosts file, then only you can use this domain with your local computer.
But, If you really want to serve some content to the Internet from your local computer you have to find a DNS server service (like cloudflare) to point your domain to your public Internet ip not to 192.168.0.102.
You configure the virtual host and set the server name to the domain name you want. After that, Apache will check the requests and will use that virtual host if a request was made for that domain name. In order for that to work, that domain should point to your IP address where the server is running.
If you want to test if the configuration works, edit your /etc/hosts file and add that domain name to 127.0.0.1. After that you will be able to access to that virtual host if you try to access to that domain name from your browser.
More info here : https://httpd.apache.org/docs/current/vhosts/name-based.html
I wanted to experiment with hosting a tiny murmur server, up to a few people.
Using a diy cartridge template, and a static build of murmur.x86, I've been able to start Murmur on the allowed OpenShift IP address.
However, how, if there's any way, would I be able to access the actual murmur server from a client, without requiring SSH > Port Forwarding from mine (and anyone else's who may want to access) local PC?
There is currently no way to expose ports other than 80/443/8000/8443 publicly on OpenShift Online. You are also able to make raw TCP connections to those ports, you can only use http/https/ws/wss. The only way to access the ports that murmur uses is over ssh port forwarding. If you would like to run a murmur server you would need to use a virtual machine that has it's own ip address and all ports exposed.
I had to reset my router and modem, after a 3 hour task of getting those working properly again I can connect to the internet.
I had WordPress running locally on MAMP and the IP address I'd connect to was http://192.168.1.141:8888, now I can't access this address at all locally, the page never properly loads. http://localhost:8888/MAMP/ does load, I can access phpMyAdmin, start page etc.
However localhost:8888 sort of 'half' loads? I can see the title of the site I have running locally in the browser tab and at the bottom it says 'connecting to http://192.168.1.141:8888' but it never loads properly.
Restarted MAMP, cleared browser cache, restarted computer etc, nothing fixes it.
While 192.168.1.141 is the address you used to connect to, after resetting your router and modem, depending on how your router assigns IP addresses (statically or dynamically), your IP address may have changed.
How to check your ip address on Windows:
Click start menu
type in cmd.exe
type ipconfig into the terminal
your ip address should be listed in the results
#gilsho: ifconfig is the *nix command, MAMP I think stands for Microsoft / Apache / Mysql / PHP.
Correction: #gilsho: you are right. MAMP is Mac, so you would use ifconfig.
http://en.wikipedia.org/wiki/MAMP
Once you confirm your ip address, we can continue to help you.
Edit: To make things easier for you, I would go into your router (usually 10.0.0.1 or 192.168.0.1) and set up your ip address to a static one (they usually make it easy for you; your mac address can be found in the ipconfig results, just assign the mac address to an ip address in the range it assigns you. That way, the router will always give you the same ip regardless of whether it is restarted or not.). This will not mean you can access your webpage outside of your router network though.
Edit #2:
Try using a simple index.html (maybe your apache comes with one) that you can try loading. Perhaps it is your webpage that bricks something while loading. In any case, it's best to simplify the problem. If you can load a simple html "hello world" page, then it's likely a problem with your code.
Edit #3:
Is your webpage using any additional technologies? You have PHP, Python, Ajax/jQuery, etc. etc. If one of these components or plugins is missing or not configured, you may also see problems such as loading issues, 405/500 errors, etc.
Routers typically use DHCP to hand out local IP address to host machines. I suspect that when you restarted your router your machine received a different IP address. In order to find your new IP address, run:
ifconfig
from the command line. The output should look something like this:
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether c9:a4:51:43:5b:1b
inet6 fe80::bae8:56ff:ae23:5c1a%en0 prefixlen 64 scopeid 0x4
inet6 2601:9:400:1185:bae8:56ff:fe43:5b1a prefixlen 64 autoconf
inet6 2601:9:400:1185:fdcd:395b:4671:7cbf prefixlen 64 autoconf temporary
inet 192.168.1.113 netmask 0xffffff00 broadcast 192.168.1.255
nd6 options=1<PERFORMNUD>
media: autoselect
status: active
search for the inet field, that's your current local IP address.
Ok well that took FOREVER to fix, but after I managed to reset my router and set all that up again I decided to use manual DHCP and just changed it back to my old local IP.
God, working with any equipment you get from an ISP is a nightmare.
DynDNS et. al. are great for not having to put IP addresses in config files... I put the dyndns domain in the config and if I ever want to change the server location I just update it in one place, and the config stays the same. But what if I want to change the port number that's used? Is there an equivalent for ports - so that I can also get what port to connect to from some service just like I get the IP from DynDNS? Or what's another solution (besides not changing the ports)?
DynDNS and DNS in general has the main purpose of not having to remember a host by its IP address. The DynDNS part comes is mostly to solve the issue of people who don't have static IP addresses, and they occasionally get new IP addresses when their DHCP leases expire.
The original intention wasn't really meant to account for someone purposely changing their IP address or port numbers. Usually a service is on a well known port that doesn't change, such has 80 for http. Depending on the protocol, you could set up a well-known port, and then have it redirect to a different port. As an example, some websites will redirect port 80 to 8080, but this is protocol dependent. This also won't work for a lot of other protocols, and you're usually stuck with the port you choose.
Using DynDNS I access three different machines behind the same router by simply adding a colon and the port number just as if I were adding it to a static IP address (ie myhome-computer.dyndns.biz:1234 ). Each port points to a different internal ip in the router. This works fine with my free host account. However, I am not aware of a port identifier that could report as the DynDNS host app does.