Behind The Proxy On Windows
In a corporate environment is quite common that users are behind proxy servers that need authorization. How/What to setup so your program can connect to the internet?
Even I have setup proxy setting ("
start ms-settings:
") in Windows system,
there are some program, that did not recognize.
MS Store problem
Strangely some times MS Store is not able to work with/behind proxy. My
solution is to open terminal and run:
netsh winhttp set proxy 10.10.10.10:3128
and run MS store from terminal:
start ms-windows-store:
Opensource / Environment
Other problem is that for most of the opensource tools like git, curl, wget,
python use the "linux way" - rely on environment variables line
https_proxy
and http_proxy
.
You can set it in command line with:
SET https_proxy=http://username:password@host:port
or put to permanently to user environment variables.
Problem could be that permanently storing this setting could expose your
password, so I do not recommend it. So I decided to create batch file that can
help me to make this setting more securely.
Problem was that I did not for way, how to enter password without exposing it
just with windows batch command. So I decided to use python for asking
password. My final batch script
set_proxy.bat
looks like this:
@echo off
python -c "import getpass; print(getpass.getpass('Enter Proxy Password:'))" >%temp%\tmpFile
SET /p password= < %temp%\tmpFile
DEL %temp%\tmpFile
IF "%password%" == "" GOTO SKIP_PROXY
SET https_proxy=http://%USERNAME%:%password%@10.10.10.10:3128
:SKIP_PROXY
As username it use windows environment variable
USERNAME
e.g. login name.
If you run this script in terminal, the setting
https_proxy
is valid in the current terminal window, so if you close it, this information will not be
available/usable for other program.
Comments
Post a Comment