Issue
Hi I am returning 200 on local / requests from the same IP but the below error when I hotspot my mobile phone to change IP and make the request
HTTPConnectionPool(host={myIPAddress}, port=80): Max retries exceeded ..... Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'
program.cs file
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls("http://0.0.0.0:5000/")
.UseKestrel(serverOptions =>
{
//Set properties and call methods on serverOptions
serverOptions.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(2);
serverOptions.Limits.MaxConcurrentConnections = 100;
serverOptions.Limits.MaxConcurrentUpgradedConnections = 100;
serverOptions.Limits.MaxRequestBodySize = 10 * 1024;
serverOptions.Limits.RequestHeadersTimeout = TimeSpan.FromMinutes(1);
});
}
NGINX - sites-available/default
server {
listen 80;
listen [::]:80;
server_name HFTest;
location / {
proxy_pass http://localhost:5000; **#edited as per comments**
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
Port Status - sudo netstat -tulpn | grep LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 635/nginx: master p
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 628/sshd
tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN 2048/API/HFTest
Any ideas on what to troubleshoot next?
Thankyou
EDIT:
Request - in python
scopes = 'openid'
url='http://{IPAddress}:80/connect/token'
session = OAuth2Session(clientID,clientSecret, scope=scopes)
token = session.fetch_access_token(url,verify=False)
endpoint = "http://{IPAddress}/{endpoint}"
headers = {"Authorization": "Bearer %s" % token['access_token'],"Accept": "text/xml"}
session = requests.Session()
response = session.request("GET",endpoint,headers=headers,verify = False)
print(response.status_code)
print(response.text)
Solution
The upstream service ip in your nginx configuration needs to be an actual ip address. You can try the localhost ip as follows
…
location / {
proxy_pass http://127.0.0.1:5000;
…
Answered By - chue x