- IIS 7.5 2008 R2
- più siti IIS Server/Windows legati alla stesso indirizzo IP, utilizzando nomi host.
- Il traffico in entrata verso i siti funzionanti correttamente.
- Le richieste Web in uscita eseguite dal codice sito back-end non riescono. Il sito remoto restituisce 404 (NotFound).
- Verificato tramite una traccia di rete che il traffico sta raggiungendo il server di rimozione.
- Le stesse richieste funzionano bene se effettuate da un sito che utilizza un indirizzo IP dedicato (ovvero non condiviso con altri siti).
Qualcuno ha qualche idea su come fare questo lavoro o cosa potrebbe andare storto?richieste Web in uscita quando non riescono a base di siti di IIS utilizzando l'indirizzo IP condiviso
traccia di Network sul server di hosting:
richiesta di successo dal sito w/non condivisa indirizzo IP:
No. Time Source Destination Protocol Info
6366 15:54:35.590463 192.168.1.76 173.194.77.121 HTTP GET /key/value/one/two HTTP/1.1
6369 15:54:35.599879 173.194.77.121 192.168.1.76 TCP http > 55407 [ACK] Seq=1 Ack=110 Win=344 Len=0
6370 15:54:35.621587 173.194.77.121 192.168.1.76 HTTP HTTP/1.1 200 OK (application/json)
6608 15:54:35.815774 192.168.1.76 173.194.77.121 TCP 55407 > http [ACK] Seq=110 Ack=357 Win=509 Len=0
richiesta non riuscita dal sito utilizzando un indirizzo IP condiviso:
No. Time Source Destination Protocol Info
9720 15:54:39.244192 192.168.1.80 173.194.77.121 HTTP GET /key/value/one/two HTTP/1.1
9760 15:54:39.256958 173.194.77.121 192.168.1.80 TCP [TCP segment of a reassembled PDU]
9761 15:54:39.256962 173.194.77.121 192.168.1.80 HTTP HTTP/1.1 404 Not Found (text/html)
9762 15:54:39.257027 192.168.1.80 173.194.77.121 TCP 55438 > http [ACK] Seq=212 Ack=1676 Win=512 Len=0
Codice:
public static HttpWebRequest CreateWebRequest(string url, string method = "GET", string referer = null, string contentType = null, int timeout = 100000, string authentication = null, string bindToIpAddress = null, string host = null)
{
var request = (HttpWebRequest)WebRequest.Create(url);
if (!string.IsNullOrWhiteSpace(bindToIpAddress))
{
IPAddress bindIp;
if (!IPAddress.TryParse(bindToIpAddress, out bindIp))
{
throw new ArgumentException("bindToIpAddress");
}
request.ServicePoint.BindIPEndPointDelegate = ((sp, rep, rc) =>
{
return new IPEndPoint(bindIp, 0);
});
}
request.Accept = "*/*";
request.ContentType = contentType;
request.Referer = referer;
request.Method = method;
request.Timeout = timeout;
if (!string.IsNullOrWhiteSpace(host))
{
request.Host = host;
}
return request;
}
string GetData()
{
try
{
string result;
var request = CreateWebRequest("http://jsonplaceholder.typicode.com/posts/1",
"GET",
"somedomain.com",
timeout: (10 * 1000),
bindToIpAddress: "192.168.27.133" /*site IP*/);
request.Accept = "application/json";
using (var response = request.GetResponse())
{
using (var sr = new StreamReader(response.GetResponseStream()))
{
result = sr.ReadToEnd();
}
}
return result;
}
catch (Exception ex)
{
return null;
}
}
Domanda sciocca ma sono gli indirizzi IP dedicati e condivisi provenienti dallo stesso ISP? C'è qualche possibilità che il vostro IP condiviso sia inserito nella lista nera? – Jacques
Sì. Stesso ISP e ambiente di hosting, Rackspace, per entrambi gli IP. Nella lista nera dove? Con il servizio esterno? Succede con tutti i servizi web di terze parti che abbiamo provato. Non penso che tutti starebbero nella lista nera dell'IP? –
Hai eseguito un IISReset dopo aver cambiato gli IP da Dedicated a Shared? –