Quantcast
Channel: Set proxy on Nano
Viewing all articles
Browse latest Browse all 5

Set proxy on Nano

$
0
0

I went through a question posted here a while back on 'Proxy Authenticating not working

Today I tried setting proxy (anonymous) up in Nano server (TP5) and it does not work for me. I used below PowerShell code :

$proxy = '10.35.178.212'
$port = 3128
$regKey='HKLM:\Software\Microsoft\Windows\CurrentVersion\Internet Settings'
Set-ItemProperty -path $regKey ProxyEnable -value 1 -ErrorAction Stop
Set-ItemProperty -path $regKey ProxyServer -value "${Proxy}:${Port}" -ErrorAction Stop

Now in order to validate that the proxy worked or not, I have to make a web request. So I used httpclient class like below but it blows up :

[192.168.1.104]: PS > $HttpCLient = New-Object -TypeName System.Net.Http.HttpClient
[192.168.1.104]: PS > $uri = [uri]::new('http://www.dexterposh.com')

[192.168.1.104]: PS >$response = $HttpCLient.GetAsync($uri)

[192.168.1.104]: PS >$response


Result                 :
Id                     : 279
Exception              : System.AggregateException: One or more errors occurred. ---> Syste
m.Net.Http.HttpRequestException: An error occurred while sending the request. --->
                         System.Net.Http.WinHttpException: The operation timed out
                            at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSucce
ss(Task task)
                            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess
AndDebuggerNotification(Task task)
                            at System.Net.Http.WinHttpHandler.<StartRequest>d__103.MoveNext
()
                            --- End of inner exception stack trace ---
                            --- End of inner exception stack trace ---
                         ---> (Inner Exception #0) System.Net.Http.HttpRequestException: An
 error occurred while sending the request. ---> System.Net.Http.WinHttpException: The opera
tion timed
                         out
                            at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSucce
ss(Task task)
                            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess
AndDebuggerNotification(Task task)
                            at System.Net.Http.WinHttpHandler.<StartRequest>d__103.MoveNext
()
                            --- End of inner exception stack trace ---<---
Status                 : Faulted
IsCanceled             : False
IsCompleted            : True
CreationOptions        : None
AsyncState             :
IsFaulted              : True
AsyncWaitHandle        : System.Threading.ManualResetEvent
CompletedSynchronously : False

WinHTTPhandler class object confirms the doubt that proxy is not being set.

[192.168.1.104]: PS >$winhttphandler = [System.Net.Http.WinHttpHandler]::new()
[192.168.1.104]: PS >$winhttphandler


AutomaticRedirection                : True
MaxAutomaticRedirections            : 50
AutomaticDecompression              : GZip, Deflate
CookieUsePolicy                     : UseInternalCookieStoreOnly
CookieContainer                     : 
SslProtocols                        : Tls, Tls11, Tls12
ServerCertificateValidationCallback : 
CheckCertificateRevocationList      : False
ClientCertificateOption             : Manual
ClientCertificates                  : {}
PreAuthenticate                     : False
ServerCredentials                   : 
WindowsProxyUsePolicy               : UseWinHttpProxy
DefaultProxyCredentials             : System.Net.SystemNetworkCredential
Proxy                               : 
MaxConnectionsPerServer             : 2147483647
ConnectTimeout                      : 00:01:00
SendTimeout                         : 00:00:30
ReceiveHeadersTimeout               : 00:00:30
ReceiveDataTimeout                  : 00:00:30
MaxResponseHeadersLength            : 65536
MaxResponseDrainSize                : 65536
So my question is how to set proxy on Nano server ?



Knowledge is Power{Shell}

DexterPOSH

My Blog


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images