Come fanno i server Web a sapere se si sta utilizzando l'accesso diretto agli indirizzi IP o no?

Sommario:

Come fanno i server Web a sapere se si sta utilizzando l'accesso diretto agli indirizzi IP o no?
Come fanno i server Web a sapere se si sta utilizzando l'accesso diretto agli indirizzi IP o no?

Video: Come fanno i server Web a sapere se si sta utilizzando l'accesso diretto agli indirizzi IP o no?

Video: Come fanno i server Web a sapere se si sta utilizzando l'accesso diretto agli indirizzi IP o no?
Video: Rendiamo smart qualsiasi lampadario con Aqara e  HomeKit - YouTube 2024, Aprile
Anonim
Di solito, digitiamo semplicemente l'indirizzo di un sito web che vogliamo visualizzare, ma un server web effettivamente "saprebbe" se usassimo invece l'indirizzo IP diretto? Il post di Q & A di SuperUser di oggi ha la risposta alla domanda di un lettore confuso.
Di solito, digitiamo semplicemente l'indirizzo di un sito web che vogliamo visualizzare, ma un server web effettivamente "saprebbe" se usassimo invece l'indirizzo IP diretto? Il post di Q & A di SuperUser di oggi ha la risposta alla domanda di un lettore confuso.

La sessione di domande e risposte di oggi ci viene fornita per gentile concessione di SuperUser, una suddivisione di Stack Exchange, un raggruppamento di domande e risposte basato sulla comunità.

Foto per gentile concessione di Cory M. Grenier (Flickr).

La domanda

Il lettore SuperUser Joseph A. vuole sapere come i server web possono capire se stai usando l'accesso diretto all'IP o no:

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?

Come fanno i server Web a sapere se si sta utilizzando l'accesso diretto all'IP o no?

La risposta

Il sostenitore di SuperUser iAdjunct ha la risposta per noi:

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.

Hai qualcosa da aggiungere alla spiegazione? Audio disattivato nei commenti. Vuoi leggere più risposte dagli altri utenti di Stack Exchange esperti di tecnologia? Controlla la discussione completa qui.

Consigliato: