Como os servidores da Web sabem se você está usando o acesso direto ao endereço IP ou não?

Índice:

Como os servidores da Web sabem se você está usando o acesso direto ao endereço IP ou não?
Como os servidores da Web sabem se você está usando o acesso direto ao endereço IP ou não?

Vídeo: Como os servidores da Web sabem se você está usando o acesso direto ao endereço IP ou não?

Vídeo: Como os servidores da Web sabem se você está usando o acesso direto ao endereço IP ou não?
Vídeo: Windows 10 - Alarme, relógio, cronômetro e temporizador - YouTube 2024, Abril
Anonim
Normalmente, apenas digitamos o endereço de um site que queremos ver, mas um servidor da Web realmente “saberia” se usássemos o endereço IP direto? A postagem de perguntas e respostas do SuperUser de hoje tem a resposta para uma pergunta confusa do leitor.
Normalmente, apenas digitamos o endereço de um site que queremos ver, mas um servidor da Web realmente “saberia” se usássemos o endereço IP direto? A postagem de perguntas e respostas do SuperUser de hoje tem a resposta para uma pergunta confusa do leitor.

A sessão de perguntas e respostas de hoje nos é oferecida por cortesia do SuperUser, uma subdivisão do Stack Exchange, um agrupamento de sites de perguntas e respostas conduzido pela comunidade.

Foto cedida por Cory M. Grenier (Flickr).

A questão

Leitor de Superusuário Joseph A. quer saber como os servidores da Web podem saber se você está usando o acesso de endereço IP direto ou não:

Some web servers, when accessed using their IP address, return an error that direct IP address access is not allowed. I have been wondering for some time how this works.

Does a browser always resolve the IP address and connect to it? Direct IP address access is just skipping DNS altogether, right? How does a remote server even know that you skipped DNS?

Como os servidores da web sabem se você está usando o acesso direto ao endereço IP ou não?

A resposta

Colaborador da SuperUser iAdjunct tem a resposta para nós:

To answer your question of how it knows, it has to do with what your browser sends the web server. You are right that the system always resolves it to an IP address, but the browser sends the URL you attempted to access in the HTTP header.

Here is a sample header that I found online, modified to look as though you used Firefox on Windows and typed apple.com into the address bar:

Here is what the header would look like if you used its IP address:
Here is what the header would look like if you used its IP address:
Both of these would be sent to the same IP address over a socket, but the browser tells the web server what it accessed. Why? Because web servers with the same IP address may host multiple websites and give different pages for each. It cannot distinguish who wants which page by IP address because they all have the same one, but it can distinguish them by the HTTP header.
Both of these would be sent to the same IP address over a socket, but the browser tells the web server what it accessed. Why? Because web servers with the same IP address may host multiple websites and give different pages for each. It cannot distinguish who wants which page by IP address because they all have the same one, but it can distinguish them by the HTTP header.

Tem algo a acrescentar à explicação? Som desligado nos comentários. Quer ler mais respostas de outros usuários do Stack Exchange com experiência em tecnologia? Confira o tópico de discussão completo aqui.

Recomendado: