When specifying a “host name”, do we still need to specify a port?












5















https://en.wikipedia.org/wiki/Virtual_hosting says




Name-based virtual hosts use multiple host names for the same IP address.




Does a "host name" correspond to an IP address or a pair of IP address and a port?



When specifying a "host name", do we still need to specify a port?



If that matters, consider only in virtual hosting.



Thanks.










share|improve this question





























    5















    https://en.wikipedia.org/wiki/Virtual_hosting says




    Name-based virtual hosts use multiple host names for the same IP address.




    Does a "host name" correspond to an IP address or a pair of IP address and a port?



    When specifying a "host name", do we still need to specify a port?



    If that matters, consider only in virtual hosting.



    Thanks.










    share|improve this question



























      5












      5








      5








      https://en.wikipedia.org/wiki/Virtual_hosting says




      Name-based virtual hosts use multiple host names for the same IP address.




      Does a "host name" correspond to an IP address or a pair of IP address and a port?



      When specifying a "host name", do we still need to specify a port?



      If that matters, consider only in virtual hosting.



      Thanks.










      share|improve this question
















      https://en.wikipedia.org/wiki/Virtual_hosting says




      Name-based virtual hosts use multiple host names for the same IP address.




      Does a "host name" correspond to an IP address or a pair of IP address and a port?



      When specifying a "host name", do we still need to specify a port?



      If that matters, consider only in virtual hosting.



      Thanks.







      virtualhost port hostname






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 11 hours ago







      Tim

















      asked 11 hours ago









      TimTim

      68731526




      68731526






















          3 Answers
          3






          active

          oldest

          votes


















          10














          Host names do not correspond to an {ipaddress,port} tuple. A host name is only the name of a server, which should be resolvable to one or more IP addresses. Ports have nothing to do with host names at all.






          share|improve this answer
























          • Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

            – Tim
            11 hours ago






          • 1





            @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

            – Romeo Ninov
            10 hours ago











          • @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

            – MSalters
            10 hours ago











          • @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

            – viraptor
            3 hours ago



















          5














          A "virtual host" is simply a feature of a piece of software which takes advantage of extra context in a request to act differently.



          An important thing to note is that TCP/IP itself does not know anything about host names; their main purpose is as a way to find IP addresses.



          The classic example is an HTTP Server using name-based virtual hosting, which works like this:




          • The user requests a URL. The domain name is looked up in DNS, to find an IP address.

          • A TCP connection is opened to a particular IP address and port. (For HTTP, this defaults to port 80; for HTTPS, port 443).

          • The client sends a request on that connection which includes whatever information is specified by the protocol being used.


            • In HTTP 1.1 this includes the "Host" header, which is the domain name the user looked up to find the IP address.

            • For a secure connection, the TLS handshake can include a "Server Name Indication" field, so that this is available before certificates are agreed.



          • The server software listening on the IP address and port now has all three pieces of information: IP address, port number, and host name; it can use these to determine which configuration to apply to the request. This configuration is the "virtual host".






          share|improve this answer































            1














            Host names are handled by DNS (or other name resolution like a hostfile). Webservers listen on IPs/Sockets, but when running virtual hosts they also look at the request header for what FQDN was used to request the page.



            When a web server running virtual hosts responds to a request, it looks at the request header to see if the request is from a host it knows about, then serves up the correct page. i.e. if i have a server with virtual host for initech.xyz, DNS will point it to the IP of my web server, which is listening on the default http/s ports (80/443). Based on the configuration you can turn on/off different ports that each virtual host responds to, but from an IP/port perspective, if the port is enabled, it's open.



            Also DNS can have multiple IPs resolving to the same name, and vice versa.






            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "2"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f953380%2fwhen-specifying-a-host-name-do-we-still-need-to-specify-a-port%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              10














              Host names do not correspond to an {ipaddress,port} tuple. A host name is only the name of a server, which should be resolvable to one or more IP addresses. Ports have nothing to do with host names at all.






              share|improve this answer
























              • Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

                – Tim
                11 hours ago






              • 1





                @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

                – Romeo Ninov
                10 hours ago











              • @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

                – MSalters
                10 hours ago











              • @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

                – viraptor
                3 hours ago
















              10














              Host names do not correspond to an {ipaddress,port} tuple. A host name is only the name of a server, which should be resolvable to one or more IP addresses. Ports have nothing to do with host names at all.






              share|improve this answer
























              • Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

                – Tim
                11 hours ago






              • 1





                @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

                – Romeo Ninov
                10 hours ago











              • @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

                – MSalters
                10 hours ago











              • @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

                – viraptor
                3 hours ago














              10












              10








              10







              Host names do not correspond to an {ipaddress,port} tuple. A host name is only the name of a server, which should be resolvable to one or more IP addresses. Ports have nothing to do with host names at all.






              share|improve this answer













              Host names do not correspond to an {ipaddress,port} tuple. A host name is only the name of a server, which should be resolvable to one or more IP addresses. Ports have nothing to do with host names at all.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered 11 hours ago









              Jenny DJenny D

              23.7k116096




              23.7k116096













              • Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

                – Tim
                11 hours ago






              • 1





                @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

                – Romeo Ninov
                10 hours ago











              • @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

                – MSalters
                10 hours ago











              • @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

                – viraptor
                3 hours ago



















              • Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

                – Tim
                11 hours ago






              • 1





                @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

                – Romeo Ninov
                10 hours ago











              • @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

                – MSalters
                10 hours ago











              • @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

                – viraptor
                3 hours ago

















              Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

              – Tim
              11 hours ago





              Thanks. (1) Can you tell me how to make a host name that can be resolve to more than one IP addresses? (2) When specifying a "host name", do we still need to specify a port? Is a host name specified with different ports resolved to the same IP address? Can a host name specified with different ports invoke different servers?

              – Tim
              11 hours ago




              1




              1





              @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

              – Romeo Ninov
              10 hours ago





              @Tim, if you have more questions feel free to create new question(s) in to the platform pressing "Ask question"

              – Romeo Ninov
              10 hours ago













              @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

              – MSalters
              10 hours ago





              @Tim: Resolving of a host name is entirely, fully, completely independent of a port number. As such, there is neither a need nor a possibility to specify a port when resolving a name. (aka "name lookup").

              – MSalters
              10 hours ago













              @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

              – viraptor
              3 hours ago





              @MSalters almost... SRV records usually specify the port of the service as well as the IP. One record can resolve to multiple ports on the same IP.

              – viraptor
              3 hours ago













              5














              A "virtual host" is simply a feature of a piece of software which takes advantage of extra context in a request to act differently.



              An important thing to note is that TCP/IP itself does not know anything about host names; their main purpose is as a way to find IP addresses.



              The classic example is an HTTP Server using name-based virtual hosting, which works like this:




              • The user requests a URL. The domain name is looked up in DNS, to find an IP address.

              • A TCP connection is opened to a particular IP address and port. (For HTTP, this defaults to port 80; for HTTPS, port 443).

              • The client sends a request on that connection which includes whatever information is specified by the protocol being used.


                • In HTTP 1.1 this includes the "Host" header, which is the domain name the user looked up to find the IP address.

                • For a secure connection, the TLS handshake can include a "Server Name Indication" field, so that this is available before certificates are agreed.



              • The server software listening on the IP address and port now has all three pieces of information: IP address, port number, and host name; it can use these to determine which configuration to apply to the request. This configuration is the "virtual host".






              share|improve this answer




























                5














                A "virtual host" is simply a feature of a piece of software which takes advantage of extra context in a request to act differently.



                An important thing to note is that TCP/IP itself does not know anything about host names; their main purpose is as a way to find IP addresses.



                The classic example is an HTTP Server using name-based virtual hosting, which works like this:




                • The user requests a URL. The domain name is looked up in DNS, to find an IP address.

                • A TCP connection is opened to a particular IP address and port. (For HTTP, this defaults to port 80; for HTTPS, port 443).

                • The client sends a request on that connection which includes whatever information is specified by the protocol being used.


                  • In HTTP 1.1 this includes the "Host" header, which is the domain name the user looked up to find the IP address.

                  • For a secure connection, the TLS handshake can include a "Server Name Indication" field, so that this is available before certificates are agreed.



                • The server software listening on the IP address and port now has all three pieces of information: IP address, port number, and host name; it can use these to determine which configuration to apply to the request. This configuration is the "virtual host".






                share|improve this answer


























                  5












                  5








                  5







                  A "virtual host" is simply a feature of a piece of software which takes advantage of extra context in a request to act differently.



                  An important thing to note is that TCP/IP itself does not know anything about host names; their main purpose is as a way to find IP addresses.



                  The classic example is an HTTP Server using name-based virtual hosting, which works like this:




                  • The user requests a URL. The domain name is looked up in DNS, to find an IP address.

                  • A TCP connection is opened to a particular IP address and port. (For HTTP, this defaults to port 80; for HTTPS, port 443).

                  • The client sends a request on that connection which includes whatever information is specified by the protocol being used.


                    • In HTTP 1.1 this includes the "Host" header, which is the domain name the user looked up to find the IP address.

                    • For a secure connection, the TLS handshake can include a "Server Name Indication" field, so that this is available before certificates are agreed.



                  • The server software listening on the IP address and port now has all three pieces of information: IP address, port number, and host name; it can use these to determine which configuration to apply to the request. This configuration is the "virtual host".






                  share|improve this answer













                  A "virtual host" is simply a feature of a piece of software which takes advantage of extra context in a request to act differently.



                  An important thing to note is that TCP/IP itself does not know anything about host names; their main purpose is as a way to find IP addresses.



                  The classic example is an HTTP Server using name-based virtual hosting, which works like this:




                  • The user requests a URL. The domain name is looked up in DNS, to find an IP address.

                  • A TCP connection is opened to a particular IP address and port. (For HTTP, this defaults to port 80; for HTTPS, port 443).

                  • The client sends a request on that connection which includes whatever information is specified by the protocol being used.


                    • In HTTP 1.1 this includes the "Host" header, which is the domain name the user looked up to find the IP address.

                    • For a secure connection, the TLS handshake can include a "Server Name Indication" field, so that this is available before certificates are agreed.



                  • The server software listening on the IP address and port now has all three pieces of information: IP address, port number, and host name; it can use these to determine which configuration to apply to the request. This configuration is the "virtual host".







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 9 hours ago









                  IMSoPIMSoP

                  1657




                  1657























                      1














                      Host names are handled by DNS (or other name resolution like a hostfile). Webservers listen on IPs/Sockets, but when running virtual hosts they also look at the request header for what FQDN was used to request the page.



                      When a web server running virtual hosts responds to a request, it looks at the request header to see if the request is from a host it knows about, then serves up the correct page. i.e. if i have a server with virtual host for initech.xyz, DNS will point it to the IP of my web server, which is listening on the default http/s ports (80/443). Based on the configuration you can turn on/off different ports that each virtual host responds to, but from an IP/port perspective, if the port is enabled, it's open.



                      Also DNS can have multiple IPs resolving to the same name, and vice versa.






                      share|improve this answer




























                        1














                        Host names are handled by DNS (or other name resolution like a hostfile). Webservers listen on IPs/Sockets, but when running virtual hosts they also look at the request header for what FQDN was used to request the page.



                        When a web server running virtual hosts responds to a request, it looks at the request header to see if the request is from a host it knows about, then serves up the correct page. i.e. if i have a server with virtual host for initech.xyz, DNS will point it to the IP of my web server, which is listening on the default http/s ports (80/443). Based on the configuration you can turn on/off different ports that each virtual host responds to, but from an IP/port perspective, if the port is enabled, it's open.



                        Also DNS can have multiple IPs resolving to the same name, and vice versa.






                        share|improve this answer


























                          1












                          1








                          1







                          Host names are handled by DNS (or other name resolution like a hostfile). Webservers listen on IPs/Sockets, but when running virtual hosts they also look at the request header for what FQDN was used to request the page.



                          When a web server running virtual hosts responds to a request, it looks at the request header to see if the request is from a host it knows about, then serves up the correct page. i.e. if i have a server with virtual host for initech.xyz, DNS will point it to the IP of my web server, which is listening on the default http/s ports (80/443). Based on the configuration you can turn on/off different ports that each virtual host responds to, but from an IP/port perspective, if the port is enabled, it's open.



                          Also DNS can have multiple IPs resolving to the same name, and vice versa.






                          share|improve this answer













                          Host names are handled by DNS (or other name resolution like a hostfile). Webservers listen on IPs/Sockets, but when running virtual hosts they also look at the request header for what FQDN was used to request the page.



                          When a web server running virtual hosts responds to a request, it looks at the request header to see if the request is from a host it knows about, then serves up the correct page. i.e. if i have a server with virtual host for initech.xyz, DNS will point it to the IP of my web server, which is listening on the default http/s ports (80/443). Based on the configuration you can turn on/off different ports that each virtual host responds to, but from an IP/port perspective, if the port is enabled, it's open.



                          Also DNS can have multiple IPs resolving to the same name, and vice versa.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 7 hours ago









                          Steve ButlerSteve Butler

                          817817




                          817817






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Server Fault!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f953380%2fwhen-specifying-a-host-name-do-we-still-need-to-specify-a-port%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Magento 2 controller redirect on button click in phtml file

                              Polycentropodidae