Showing posts with label proxy. Show all posts
Showing posts with label proxy. Show all posts

Wednesday, January 29, 2014

Register and Download Books Using Kindle for PC While Behind Proxy

Yes, this is another story of proxy workarounds. If you're interested in my other exploits, you can read them here, here and here

A little background. I have several Kindle ebooks that I can read using my mobile phone and my pc at home. Now, I wanted to read here at work but I can't seem to register and download my ebooks, so here's what I've done to overcome this limitation.

1. Of course, I installed Kindle for PC (K4PC). My OS is Windows 7 but I think if you're using another OS, you can "translate" these instructions compatible for your OS.

After downloading the app, I tried to register it to my account but I got this error: Unable to connect at this time. Please try again later.

Not surprising, since I know I'm behind a proxy. I checked if the app has settings for proxy and it has one. To open the proxy settings, click Tools > Options > Network.

I chose Manual proxy configuration since I know my username and password. After saving the settings, I tried registering again and I got this error: Registration timed out. Please try again [1000]

Which is weird since I know I have internet connection and I have filled up the proxy setting properly. I googled kindle for pc proxy and found out that many people have this same dilemma and most of them came to the same conclusion as I did: You cannot use your Kindle (pc or otherwise) when you're behind a proxy. 

Then I stumbled upon Scott Offen's post on Registering Amazon’s SendToKindle Behind A Proxy. Now I'm not familiar with SendToKindle app but then since he solved his Kindle-related problem, I decided to give his solution a try.

His solution is actually simple: use Cntlm proxy. You can read the technical description from its official sourceforge site but for the non-geeks out there, basically Cntlm is a proxy for your proxy.

I'm not a newbie with this application/service. As a matter of fact, I have already used it for downloading gems for my Ruby on Rails in Ubuntu while behind proxy. My previous post details on how to use Cntlm in Ubuntu, we can use the same steps here while using Windows 7.

2. Install Cntlm.
3. Open cntlm.ini using your favorite text editor. You can find it in this path: C:\Program Files (x86)\Cntlm (or depends where you installed your Cntlm).
4. Edit the Cntlm configuration. Enter your username, domain and parent proxy as basic settings. DO NOT enter your password. 
5. To hash your password: 
- Open a command prompt. 
- Go to your Cntlm installation folder by typing: cd C:\Program Files (x86)\Cntlm
- Type: cntlm -v -H -c cntlm.ini
- Enter your password for your proxy and jot down the generated PassLM, PassNT and PassNTLMv2.
- Open cntlm.ini again and enter the generated PassLM, PassNT and PassNTLMv2 to their respective fields. Then save your new settings.
5. Run Cntlm service. You can:
- Click Start > Windows Control Panel > Administrative Tools > Services. Start Cntlm Authentication Proxy service. (Shortcut: Open search/run textbox, type services.msc) OR
- Open command prompt as Admin and type net start cntlm (to start the service) or 
net stop cntlm (to stop the service).
6. FINAL STEP: Open Kindle's network connection settings (Tools > Options > Network), choose
Manual proxy configuration. In HTTP Proxy field, type: localhost and in the Port field: 3128. Leave the other fields blank.

That's it. Register your K4PC and start downloading your books. 

Happy reading! 

Sunday, November 11, 2012

Setting up Proxy Settings for apt-get and wget in Ubuntu

To check if you have proxy configured in your system:
env | grep proxy

To setup proxy, add the following lines to these environment settings:

1) apt.conf (for apt-get)

sudo gedit /etc/apt/apt.conf

Acquire::http::Proxy "http://username:password@proxy:port";
Acquire::https::Proxy "http://username:password@proxy:port";
Acquire::ftp::Proxy "http://username:password@proxy:port";

2) wgetrc (for wget)

sudo gedit /etc/wgetrc

https_proxy  = http://username:password@proxy:port
http_proxy = http://username:password@proxy:port
ftp_proxy = http://username:password@proxy:port

Uncomment 'use_proxy = on'

Then reboot. sudo reboot


After rebooting your machine, you can now use apt-get and wget normally like sudo apt-get install package-name and wget url

If you don't want to change any configurations and just wanted to use proxy for the entire duration of your session:

For apt-get:
sudo http_proxy='http://username:password@proxy:port' apt-get install package-name

For wget:
export http_proxy='http://username:password@proxy:port' && wget url

OR

export http_proxy=http://proxy:port && wget --proxy-user=user --proxy-password=password url

Things to remember: 
1) Use this format if your proxy doesn't require login credentials: http://proxy:port
2) If your proxy server is Windows-based just like ours, don't forget to add your domain in your login.
ex. http://domain\username:password@proxy:port
3) Character escape your password if it has special characters.
ex. proxy-password=me\@123
4) If after setting up the http_proxy environment variable for wget and the connection still fails, also set up the https_proxy and ftp_proxy variables.