Ubuntu proxies – Grant your server access through the firewall

Once again I bumped into a proxy issue, but now I’m inside a *nix environment.

I recently installed an Ubuntu 12.04.3 LTS server inside a virtual box, primarily to be used as a web server for my GitLab repo management. I was following this installation guide when suddenly in step 2, I encountered an error, something like this:

curl: (7) couldn't connect to host

Curl couldn’t seem to connect and download the ruby-2.0.0-p247.tar.gz file. Well since I thought this is just an isolated case, I opted to manually download the file and untar it. This is all fine with me until I encountered the next error:

ERROR:  Could not find a valid gem 'bundler' (>=0), here is why:
          Unable to download data from https://rubygems.org/ - Errno::ETIMEDOUT::
 Connect timed out - connect(2) (https://rubygems.org/latest_specs.4.8.gz)

This is just annoying because I know very much that this is a proxy issue. I’ve encountered this in the windows environment and I managed to fix it, as elaborated in this post. But inside ubuntu, much more a server, without any GUI (definitely not my cup of tea), I braced myself for a daunting task. Good thing, through hours of research, these valuable info popped out and saved me from spending precious time troubleshooting stuff.

Below is the gist of the links above (credits to Baltusaj, geirha, Julian Knight, izx and the others involved in the discussion).

 

WAYS TO IMPLEMENT THE PROXY

 

>> ONE-AND-DONE USAGE

If you need to access the internet but you don’t want your proxy getting saved on a configuration file, you can do this:

sudo env http_proxy=http://<user>:<password>@<server>:<port> apt-get update

The magic command is the env http_proxy because this will carry your credentials to be able to pass through the wall.

 

>> THROUGH CONFIGURATION FILES

If you think you’d need to go back and forth through the firewall, typing the commands mentioned in the previous point would be a hassle. Below are the options:

:: Through the environment configuration file

This is the setup that worked for me.

  1. Open /etc/environment file
  2. Add the ff. variable-value pairs (enter both upper and lower case variables since applications only look for one or the other:
    1. http_proxy="http://<server>:<port>"
    2. HTTP_PROXY="http://<server>:<port>"
    3. https_proxy="http://<server>:<port>"
    4. HTTPS_PROXY="http://<server>:<port>"
    5. ftp_proxy="http://<server>:<port>"
    6. FTP_PROXY="http://<server>:<port>"
    7. no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
    8. NO_PROXY="localhost,127.0.0.1,localaddress,.localdomain.com"
  3. Save it and you’re done

 

:: Through the 95proxies configuration file

According to izx of askubuntu.com, In some cases, apt-get, aptitude, etc. will not obey the environment variables when used normally with sudo. Configure them separately inside this file.

  1. Open /etc/apt/apt.conf.d/ directory
  2. If the 95proxies file does not exist, make one
  3. Add the ff. variable-value pairs:
    1. Acquire::http::proxy "http://<server>:<port>";
    2. Acquire::https::proxy "https://<server>:<port>";
    3. Acquire::ftp::proxy "ftp://<server>:<port>";
  4. Save it and you’re done

 

DON’T FORGET TO RESTART YOUR SERVER.

 

Enjoy!

unknown filesystem type ‘vboxsf’

I’ve encountered this error when I was trying to mount a shared folder. By the way, this is the environment that I’m using:

  • Virtual Machine: Oracle VIrtualBox
  • Host: Windows 7
  • Guest: Ubuntu 12.04 LTS server

According to this post in the virtualbox forum, one of the things that I have to do to share a folder between my host and my guest is to type this command:

sudo mount -t vboxsf share ~/host

However, this might almost be the same line of code that brought you to this post because of the error you encountered. The author of that post in the vbox forum instructed beforehand that the guest additions must first be installed. However, I missed that part for some reason.

When the error popped up, I went back and tried looking at the guest additions installation procedures that was included in that post, but I felt like I’m gonna drown with all those preparations that I need to do just to install the GAs.

In the midst of my research, I found a solution; a quickfix, although I can’t guarantee that this works 100% the same way as his procedures. All I can say is, this fixed my problem.

There is a package called virtualbox-ose-guest-utils that aids in the data-sharing between the hots and guest.

Simply type this:

sudo apt-get install virtualbox-ose-guest-utils

Make sure your proxies are set for an uninterrupted download of updates, then redo your mounting.

There you go, that should work. Cheers!