CS 75 Lecture 0: HTTP

root
root servers know who the authority is for .com .net
bubble up to these very high level root servers and bubble down to the authority who does know
When we buy our domain name- tell the world , what the ip address is of your DNS serverSo someone tell it proacively once when we buy the DOMAIN


a.b.c.d
Once the ip has been resolved, the computer puts together a message as follows
Message Content: { has 3 parts }---------------GET / HTTP/1.0
Method - { / } The root   HTTP/Version NumberIn reality , there are more HTTP headers that are sent from browser to server
You can see those in action in just a bitThis message captures really the more important aspect of the request.
Our computer creates a Virtual envelope - This envelope has a message like the above 
Front of that Virtual envelope is an ip address 1.2.3.4 or what ever the googles ip address isIn the return field of this virtual envelope, there is a return address - which is your ip addressYour computer does know its ip adddress - if you have an internet connection
And then your computer sends it out on the internet
#-----------------------------Now dive in deeper deeper and deeper
Assume - isp has default gateway - router router knows how to get data from a- b , or know who to pass it off to to get it closer to point B#---------------------The packet - which is the virtual envelope - gets passed on from router to router - as many as 30 hops some timestill it finally gets to its destination google.com
Google receives this virtual envelope, sees that its for its ip address
Then it opens the envelope up and see this message 

Google.com server happens to be running a webserver and this webserver This webserver looks for a file called "/"  
"/"  is a synonym for a actual file name"/"  is actually a synonym for index.html or index.php or any of the default file names
Google grabs that file from its hard drive - Puts it in its own virtual envelope - flips the two ip addressesThe from and the sender - Sends it back to the internet via these routers 
It arrives on my computer  --- My computer opens this envelope - it sees a whole bunch of language called HTMLrenders that HTML top to bottom 
I see the search page for googles Main site
#--------------------------------------------------

When ever you type in a URL , there are several different components to it
http://www.google.com/
http typicall, followed by ://  and followed by something like this
#--------------------------------------------------------------------------
This is what we say is a representative URL
http is the protocal or schema at the beginning
https, ftp, sftp - some of these are more standardized than others.
Schema is typical for that piece of software on how it should view the contents at that address
#----------what comes after the  http:// is - we have a hostname or subdomain Name                                 - followed by the domain Name - [ which in this case is google.com ]                                 - of followed by the domain Name with TLD [ Top level Domain ]                                                                           [ .com .edu. .in .uk ]                                 - Then we have what we call the PATH                                    PATH specifies exactly what file / folder you want to access                                    so a single "/ " slash means get me the root of the hard drive                                    Windows  c:\                                     Linux   /                                   So its typically the root of the hard drive inside of which everything lives
In todays browsers - we can omit  http   , www  and things will still work   because the browsers have gotten more user friendly

Some websites - foo.com doesnt work and we have to type in   www.foo.com                - DNS and webserver configuration
Browsers - these days if they dont find an ip address associated with foo.com , then they presumptiously prepent www to the start of           the address and then retry that one           Some of the servers automatically try - .com , .gov , .net            The technical processes that are happening are hidden by the browser user friendlyness

#--------------- The above is the perspective of the USER -----------------------
LAPTOP has an ip address - it is not publicly accessibleYou do not have public ip address
COMCAST  - CABLE - you have one ip address
Three brothers and everyoen - all of them share the same ip address
So- All the users at home share the SAME PUBLIC ipaddress of the router 
When you are in home network - you have a private ip address
192.168.x.x192.168.x.x - The last digit cant be 0 or 255 - so roughly 250 ip addressesThis is the ip address that can never be given outThese are the ip addresses that can never exist  on the internet
If you dont like that172.16.x.x  - More constraints on this one 
If you really need a lot of ip addresses - you can have a CLASS A private NETWORK10.z.z.z  10.anything is a private address
This give you millions of ipaddresses for your home or data center
Any ip addresses beginning with these - their prefixes are considered private 
Even if after this class - you know HTML, CSS , PHP and JAVA SCRIPTapache - no one will be able to visit your website  because the ip probably start with this private ip address
YOUR home router cable modem or dsl modem will not allow OUTSIDE random people into your home network to access this ip addressPratically - there are 10s and 1000s of people who have the same ip address , which is not uniquely identifiable.
 Home router and cable modem, firewall - In Short that it will not work
#------------------------ HOW to make it work : -------------------- PORT Forwarding  HTTP - using other protocols behind the scenesTCP-IP buzz word TCP-IP  Two different standards - that govern how data can be transmitted on the internet - [ over simplification ]
 IP  { internet protocol } is just a set of conventions that humans came up with years ago, that govern how you associate     numeric addresses with Computers
 IP address derives from this protocol - IP is the standard for assigning these computers addresses  Assigning someone an address doesnt mean that you can get the data to that Address
 You need another standard - another protocol - that is typically TCP { transmission control Protocol } This is the standard that web browsers and web servers speak to move the data from Point A to Point B using the higher level of notation, that is the IP address that actually uniquely identify the Point A and Point B
 For those for networking TCP/IP Stack ------------- Transport layer down here  I/P or the Addressing layer So - much of the internet is simply people design things - and others design things on top of things      We over simplify them and say TCP/IP
  TCP IP not just allow WEB to work, but all sorts of applications   EMAIL, INSTANT MESSAGING, Spotify,   Dedicated applications, that are using the internet that arenet necessarily inside of a browser 

A server can actually do multiple thingsIt can receive E-mail  - like gmailIt can serve a website and receive HTTP Traffic


How 

So as a server can do multiple things, it should have a way to uniquely identify various things that it can doSo - the world introduces this notion of port numbers
For typically A Webserver rather than http, it uses this protocol TCP   80 - Number 80 will arbitrarily identify this service If you have a server, and you have a website it is running on HTTP and listening on port 80If you also have a email service running on the same server, then we can also use TCP but port 25
HTTP : TCP 80SMTP : TCP 25


If you go to gmail.com , you need a website back, if you did not insert port # 80, it is automatically inserted by the browser for youIf you send an email - then that program is going to send data to gmail .com ,but specifically to PORT 25

When a computer is on the internet and is listening for traffic, all of this traffic comes in on a specific portA specific pathway into the server
That it knows if it is a webpage or an emailThat it knows a webpage or an Email Email can contain HTML now

HTTPS : uses port 443
http://www.w.x.y.z:80http://w.x.y.z/http://w.x.y.z:81/
Restriction on port numbers, you cant use 81 - but the point is the sameThe browser is inserting the port number for you 
using non-standard ports is bad

Using non standard ports is BADAny port  using  other than 80 and 443 are blocked in most companies
PORT Number is just a basic mechanism to block traffic

Based on your router , just download the manual and configure port forwarding
If you have a popular website - Verizon / comcast will shut you off entirely.Disclosure says: You may not run website on your home computer 
I dont want my website to run on w.x.y.z, but i want it to run on  vikas.comSome url, that has distinctively my name

How do you go about getting your own domain Name :#-------------------------------------------------
godaddy / namecheap  - Sells you a domain Name - When you purchase - paying more for domain Name is not giving you anything in terms of functionality

Once i purchase the domain Name, i will have to tell the world what would my associated ip address be with this domain.
I would tell the Registrar - Not what the ip address of my compter is , but  What the ip address of my Domain Names DNS servers would be
The convention is typically , Every domain name should have two DNS servers -- primary and secondary
They can be one and the same, but the world usually pushes for two for the sake of uptime and redundancy
I need to know what my ip address is - but the IP addresses of 1st and 2nd DNS Servers
I dont have my own DNS serversI dont want to configure two more servers - in addition to my webserver
This is where the web hosting companies come in

In addition to buying the domain name, i can also host my website some where It could very well be the exact same company
It could be go daddyIt could be Namecheap depending on the service that they provide
#---------------------------------------------We need to have a web hosting option
They will have a hard drive They will also have a pool of ip addresses
They will have a technical support staffThey will have everything to keep a server live on the internet
They will also have atleast 2 of DNS servers

Lets say i have  cheaphost.com
6.85  / 8.95 / month
upload html and css to their server
Once i know what the dream hosts ip addresses are for its Name servers I tell namecheap/ go-daddy / where ever i bought my domain name 
Once this is done, we do not have to speak with the registrar till one year , when they again charge 5.99 or something
Unfortunately, we are not buying , but just renting out the domain name
There is this other stuff involved in seting up my webserver and getting my files there -But for now, i have told the world - if you want to know what david.com is , ask these peopleThose DNS servers should hopefully know what the ipaddress of my domain Name is. - WHY ?
So as long as We keep paying money to namecheap.com , or godaddy.com Paying dreamhost or someone else 8.99 /month, they will ensure that those DNS servers will know what my websites IP Addresses is
How will they know ? - What i am paying for for the Storage Space, interconnectivity on one of their hosts, that has an ip address - they will just tell the DNS servers  the david.com 's  ip address is what ever the server they have told to put my content on.

#------------------------------Frequent problem  www.something.com works                      something.com doesnt work
Make sure there is a DNS record associated with www.something.com  and also  something.com Also ensure your webserver accepts traffic to something.com in addition to www.something.com 
Lets focus on just this DNS piece for now.
DNS is relatively straight forward -

Maybe you have emailserver , you want to use  - google services - google docs 
So - Gmail is used to host cs75.nets email 
we want something like   mailin.cs75.net   -  - We could setup our own mail server
 But there is an amazing service out there

 A Name C Name MX Record NS Record - is a record in DNS server tells the world, what the ip address is for the domain.
Whats inside a DNS server ? -     - ITS a Database    - ITS a Database with excel files    Spread sheets that just has rows and columns    Those records - in each row  you have                    Domain Name  - IP Address                    Domain Name  - IP Address                    Domain Name  - IP Address    Thats really all whats underneath the hood in the DNS Server

There are different types of rows.One of the rows can be an official Record - that says           The name server NS - for this domain is what ever the IP Address Dreamhost gave me.

An A Record -------------- A Row of Type A - in spread sheet Literally - Domain Name - IP Address             something.com    w.x.y.z         mail.something.com   w.x.y.z        docs.something.com   w.x.y.z    calender.something.com   w.x.y.z
These days, its just a web interface.
Its essentially a spread sheet.CNAME------Fancier features -   CNAME - a Canonical Name is an Alias So, these days, all these services that google is providing - you dont necessarily have to know, what googles ip address is
So this looks like 
Domain Name -  Domain Name instead of  Domain Name - IP Address
So instead of mapping your service to an ip-Address , that changes/bound to change              Map your services Domain Name to the Other Services Domain Name              Domain Name - Domain Name              -------------------------

Lets say someone else is implementing a customerservice for Dell - [ customerservice.com ]So dell feels embarassed to let users route to customerservice.com , So instead What dell does it              support.dell.com  should resolve to customerservice.com but the user should not know that
         CNAME record                support.dell.com --- customerservice.com 
We dont care what the ip address is We want our domain name to be a synonym for some other elses domain Name - We use a CNAME Record
MX Record---------Mail Exchange record - or Main Change RecordSimply states that - what is the ip address of the server/s  what should handle the inbound mail for this domain Name                     gmail/outlook    davidmalan@hardward.edu
                 Websites that have large number or users that do not want their mail servers going down.                 They will configure                 HA mailservers have multiple mx records with priorities , so that we have multiple records                 with priorities, so then the dns servers will say Try this one, then this one and this one                  -then this one, just in case any of those go offline - ALL  Thanks to DNS

Having these abilities is very powerful and it really boils down to these basics if you are hosting your own company
#----------------------------------------------------------------------------------------------------------------------#----------------------------------------------------------------------------------------------------------------------
SQL - structured query language - used - for courses project    - Use Javascript to get back more data       Ability of AJAX to use Javascript to get back more data
Webservers - websites  - Databases
People dont check the code for Dangerous characters       Cross site scripting       SQL Injection  and Any number of other ways, it is so darn easy

Last lecture - USE scalability
Lecture 0-8 - Website starts crumbling under the load            - Build for several 1000            - How do you scale             - Scale horizontally            - Load balance with traffic across            - How do you do with cloud computing ?            - In addition to set of lectures -            -

#----------------------------- What are these hosting services promising to the customers ?
 Unlimited - storage - websites - databasesThey promise the same to 100 different people
So, in servers, we do have a feature of Virtual hosting
So back in the day, every website had a unique ip address wwwsomething.com , the site had an ip address associated with it
If you wanted to get a second website - then get a second server or atleast give that server a second ip addressIn more recent versions of HTTP and through experimentation , we see that browsers send another HTTP headerThey dont just send GET. They also send a reminder to the webserver as to what the user typed in the URLSo that you can now have these days multiple websites , david.com, bass.com ,foo.com, bar.com all living on the same physical server at the exact same ip address, because the Browsers remind the server what the user typed in.
So the servers, even though its serving traffic for 3 different websites, can figure out from the so called headerswhat was requested and then return the appropriate domain home page.
Its great that we can multiply this way and we can put multiple people / multiple websites on the Same IP Address Gotchas - If the machine crashes all of the websites are effected         - Contention for resources            You are kind of in bad luck if one of the other websites on the same server is facebook.com         - Just because your website is on the same server - your 

It could be a 1000 other customers on the same server
There needs to be a fine catch here8.95/yr is kind of costlyNot guarenteed is unlimited uptime
Place for testing a website 
quiet complling
E-mail or calender can be guarenteed by googlesuppose you are not so comfortable to share or be managed by other people
if you want to run php you can not upgrade different versions of software
Its too frustating not to have administrative access to the servers
In the vps worls, you get the illusion of dedicated access to your hosts
buy a cpu , buy a server, generally known as hypervisor
once you run them and install them on your server- create the illusion of multiple 
Even though they are sharing the same physical hardware, they are not 
root login to your machine, you may over provision19.99 a month159 for 19.99 a month
If you are following along - what is the you are gaining
 CONTROL - keep things up to date - where as the web hosting is compromised - everything is not perfect
 its a dedicated or virtual server to you 
 Even if they dont know your password - they may have physical access 
 "Linux can be boot up in single user mode by hitting the letter S In some of these systems, some softwares of the system administrators will have 
 




Comments