Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 4 years ago.
Improve this question
i was thinking of having 2 websites, and i'd write all my stuff (not using wordpress hosts for example). As far as i understood i can "link" several urls with a single web-hosting server. (Let's suppose i'd use a windows host, just because i'm more comfortable with windows than Linux).
But how do i make that actual server work? Before spending money i'd like to know what i'm getting into.
All i can think of is i'd run the server program (like "node server.js"), but how does the url connect someone to that program instead of another "server.exe" in the same host? How does it all work? Everytime i look for tutorials or examples i get stuff that aims to non-programmers to "make your website easy using our templates". I dont want that.
As i said, this question has nothing to do with relative vs absolute urls. I've no idea where the one that flagged it has read something like that in my words.
Let's split it in parts, shall we?
As far as i understood i can "link" several urls with a single web-hosting server
If by that you mean that you can have more than 1 domain name for your web-server; yes you can.
A domain name is something like "www.google.com" for instance.
So I understand that you're asking if you can have two different domain names, like "www.myweb.com" and "some.other-domainname.org" to point to your machine that will be hosting your website.
Yes you can. You should take a look on what a Domain Name System is.
But basically, what a DNS does is translate these names into actual IP addresses. This is done by having something called a name table that could look like:
"www.google.com" -> XXX.XXX.XXX.XXX (for IPv4 as an example)
"www.youtube.com" -> AAA.AAA.AAA.AAA
Since this is done by some kind of mapping you will also need a static IP address.
Both, static IP adresses and domain names must be bought or rented.
The way the things are connected, they also have to do with the ports where they operate. For instance, http requests operate in port 80 and SSH typically in port 22 if I remember correctly.
So what your web-server would do something similar to this:
listen to port 80 -> read the requested file (specified within the URL request) -> send it through that port 80 along with the http headers and payload as a response.
After that the browser requesting the file would read that http response, parse it and show that info into the actual window of the browser.
And you can also rent a webhosting service.
A webhosting service is basically somebody that already dealt with all of this gibberish and has machines that are ready to serve web content. You only have to upload your website into their webserver.
You can also buy a domain name and make it to point to that rented service
To host your own webserver you need to decide which webserver to use:
You basically have two options: Apache or nginx
As you are hosting on windows and are only using the server for developing I can recommend XAMPP, it contains Apache, MariaDB(SQL Database based on MySql),PHP and Perl. Installation is usage is straight forward but if you want here is a tutorial to use it.
As Tripp Kinetics pointed out, you should probably check out some HTML tutorials or buy a book.
I am on a windows machine and programming in Go. When I do an ipconfig I am able to see my machine's interfaces.
Whenever I execute net.InterfaceAddrs() I get a bunch of IP addresses, and I know which one is the one I am looking for, but I want to be able to tell if those addresses belong to my domain. In the output of ipconfig I can tell this by reading the Connection-Specific DNS Suffix entry which has my "company.com" listed.
Any ideas?
See: similar question
try net.LookupAddr for each IP you get from net.InterfaceAddrs
assuming they reverse back correctly, they should end in your domain name.
I'm working on app to find routes between 2 address via SNMP.
The app needs to support multiple MIBs.
For MIB 2, I was able to query routing tables e.g ipRouteNextHop, etc.
In CISCO-CDP-MIB, is it possible to find next hop address?
If so, which OID is it?
I've looked at the OIDs, but couldn't find any info about hop address (perhaps I missed it).
No, there isn't a guaranteed way to get next-hop from the CISCO-CDP-MIB; the problem is that CDP only advertises one IP address for the entire machine, and there is no assurance that the IP address used by CDP is your appropriate next-hop. I am not sure why you don't want to use ipRouteNextHop, but that is a fine way to discover routing information for any big-name commercial routing platform.
This is a "Blocked Port 80" related question, but maybe something a bit unique. I've yet to find a good answer. It's more academic than anything as I know running a production server at your house is a ridiculous idea.
I'm running a development server (LAMP) at my home but my ISP blocks port 80. The DNS for my domain is set up to "URL Redirect" to my IP and port number. My router is port-forwarding to my server, and I have Apache set up so it's listening on port 8081.
The issue is that when you access the domain, the URL in the browser is resolved from my domain name to the IP and port number, and is displayed as such. For example, you type "www.banana.com" into the browser, the site is displayed but now the URL is shown as "12.23.456.11:8081".
Is there any way to fix this so that the domain name does not become IP and port number?
Can you use Apache proxy functionality somehow?
Could you use mod_rewrite to change the IP and port number back to the domain name?
Thanks in advance!
This question has three parts. First the issue of the domain: in order to substitute a domain name in place of an IP address you need some name server that can map your desired name to an address. This is at the host level and not the port level so a domain name will encompass all ports you might host from it. If you are using your home Internet connection (which I suspect you are since you talk about a blocked port) then you need to take into account that from time to time your public IP address can change. Your options are to pay for (or request) a static IP from your ISP or use a dynamic DNS service that can rapidly update their records as your IP address changes.
As for your port number. Mod_rewrite only handles the path part of a URL, for using different ports internally you want mod_proxy. The Apache web sever with mod_proxy would be configured to listen on the public port you want (that I assume is port 80) then mod_proxy would take incoming requests and send them to another web server on a different port (or even different server). To the outside user this happens invisibly. The problem is if your ISP wont let you host your site on port 80 then it logically won't let you proxy from port 80. To get around this would be a little harder. Personally I would look at a virtualized server from people like Rackspace or Linode. You would get (for relatively little money) a fully configurable server on the open Internet with no restrictions on port usage and a static IP. Even better if you mess something up you can just virtually delete your server and start over with a fresh OS image.
Finally the clean URLs your question title suggests. It's possible this wasn't part of your actual question but just in case, mod_rewrite is a smart module that can let you map clean URLs like /cars/Toyota/1997 and turn them into more ugly requests like /cars.php?make=Toyota&year=1997. Clean URLs not only look better they make it easier to reorganize web code behind the scenes as your web site evolves.
One last thing, and its amazing to me that this question has gone so long without even a comment about this but, this question is really not a good fit for StackOverflow. Possibly ServerFault.com. Good luck! :)
Consider the following setup:
A windows PC with a LAN interface and a WiFi interface (the standard for any new laptop). Each of the interfaces might be connected or disconnected from a network. I need a way to determine which one of the adapters is the one connected to the internet - specifically, in case they are both connected to different networks, one with connection to the internet and one without.
My current solution involves using IPHelper's "GetBestInterface" function and supplying it with the IP address "0.0.0.0".
Do you have any other solutions you might suggest to this problem?
Following some of the answers, let me elaborate:
I need this because I have a product that has to choose which adapter to bind to. I have no way of controlling the setup of the network or the host where the product will run and so I need a solution that is as robust as possible, with as few assumptions as possible.
I need to do this in code, since this is part of a product.
#Chris Upchurch: This makes me dependent on google.com being up (usually not a problem) and on any personal firewall that might be installed to allow pinging.
#Till: Like Steve Moon said, relying on the adapter's address is kind of risky because you make a lot of assumptions on the internal network setup.
#Steve Moon: Looking at the routing table sounds like a good idea, but instead of applying the routing logic myself, I am trying to use "GetBestInterface" as described above. I believe what it should do is exactly what you outlined in your answer, but I am not really sure. The reason I'm reluctant to implement my own "routing logic" is that there's a better chance that I'll get it wrong than if I use a library/API written and tested by more "hard-core" network people.
Technically, there is no "connected to the Internet". The real question is, which interface is routeable to a desired address. Right now, you're querying for the "default route" - the one that applies if no specific route to destination exists. But, you're ignoring any specific routes.
Fortunately, for 99.9% of home users, that'll do the trick. They're not likely to have much of a routing table, and GetBestInterface will automatically prefer wired over wireless - so you should be good. Throw in an override option for the .1% of cases you screw up, and call it a day.
But, for corporate use, you should be using GetBestInterface for a specific destination - otherwise, you'll have issues if someone is on the same LAN as your destination (which means you should take the "internal" interface, not the "external") or has a specific route to your destination (my internal network could peer with your destination's network, for instance).
Then again, I'm not sure what you plan to do with this adapter "connected to the Internet", so it might not be a big deal.
Apparently, in Vista there are new interfaces that enable querying for internet connectivity and more. Take a look at the NLM Interfaces and specifically at INetworkConnection - you can specifically query if the network connection has internet connectivity using the GetConnectivity method.
See also: Network Awareness on Windows Vista
Unfortunately, this is only available on Vista, so for XP I'd have to keep my original heuristic.
I'd look at the routing table. Whichever NIC has an 0.0.0.0 route AND is enabled AND has the lowest metric, is the nic that's currently sending packets to the internet.
So in my case, the top one is the 'internet nic'.
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.0.0.10 10.0.0.51 20
0.0.0.0 0.0.0.0 10.0.0.10 10.0.0.50 25
(much other stuff deleted)
Another alternative is to ping or GetBestInterface 4.2.2.2 - this is an old and venerable DNS server, currently held by GTEI; formerly by Sprint if I remember right.
Start > Run > cmd.exe (this works in XP and Vista): ipconfig /all
This displays all info about the interfaces in your computer. The "public" facing interface should have a public IP address. For starters, it should not be 192.168.x.x or 10.x.x.x :)
running traceroute to some public site will show you. Of course, there may be more than one interface that would get you there.
Look at the routing table? Generally, unless you're routing between the networks in windows (which is possible, but unusual for a client computer these days) the interface that holds the default route is going to have the Internet connection.
Your question didn't detail why or what you're doing this with so I can't provide any specifics. The command line tool "route" may be of some help, but there are probably libraries for whatever programming language you're using to look at the routing table.
You can't rely on the IP address of the interface (e.g., assuming an RFC-1918 address [192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8] isn't the internet) since most sites have some kind of NATed firewall or proxy setup and the "internet" interface is really on a "private" lan that gets you out to the Internet.
UPDATE: Based on your further information, it sounds like you have a decent solution. I'm not so sure about the choice of 0.0.0.0 since that's a boundary case for IP address -- might be OK on your particular mix of platform/language. Sounds (from the API description) like you could just specify an address, so why not some address known to be on the Internet, e.g. the IP address of your web site, or something more random like 65.66.67.68? Just make sure not to pick one of the rfc-1918 addresses, or the localhost range (127.0.0.0/8), or multicast, any other reserved range, and any address that resolves to a .mil or .gov (while it doesn't sound like getbestinterface sends any traffic, it would suck to find out by having the feds break your door down... :)
Looking at the network point of view, either could be routing to the "internet" at any time. If things like spanning tree protocol are enabled on a switch then you may find that what may have been the routing card to begin with may not be anymore.
Ping google.com though each NIC.