• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how does a website know what subdomain a request comes from

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there are websites out there that have the following url schema
http://[uniquesubdomain].example.com

so in our example we will use these 2 urls.
  • http://companyA.example.com
  • http://companyB.example.com


  • When you go to http://companyA.example.com the logo for the company shows up on the landing page.
    The same happens when you go to http://companyB.example.com

    How does this work?

     
    Bartender
    Posts: 9626
    16
    Mac OS X Linux Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    It's basically a trick with DNS. The first part of a fully qualified domain name refers to a host (like ftp.x.com or www.x.com). These hosts can be real (i.e. unique machines) or virtual (many hosts on the same server). Each host can serve its own unique content.
     
    Tim Sparg
    Ranch Hand
    Posts: 40
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I've been browsing around trying to work this out - I think this is how it works, but then again I might be conpletely misdirected

    http://companyA.example.com resolves to myserver:765
    http://companyB.example.com resolves to myserver:234

    Either your application picks up what port the request is coming through and from there is able to serve unique content for the company/user
    OR
    You have some kind of proxy/filter sitting in front of your application that puts something into the http header like "companyCode", then your application is on the look out for the companyCode http header

    Does any of this sound roughly right?

     
    Joe Ess
    Bartender
    Posts: 9626
    16
    Mac OS X Linux Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    There's probably many different ways to implement this functionality.

    Either your application picks up what port the request is coming through and from there is able to serve unique content for the company/user


    Your application, if it is a "normal" web application, is going to be mapped to a single port. It is more likely one would use virtual hosts to implement the proxy idea and forward to a content management system.
     
    Ranch Hand
    Posts: 2187
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Domain names are mapped to point to "physical" locations on a server machine, i.e. machine with web server. A DNS server handles the search and find operations.

    In regards to "knowing" which domain a HTTP Request came from, this information is in the HTTP headers of the request.

    To learn more about how this works, find material on DNS server operations and HTTP headers.
     
    Lasagna is spaghetti flvored cake. Just like this tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic