1.) Update your environmental variable
The first step is to create exports in your environmental variables and you can do that by editing /etc/environment
sudo vim /etc/environment
In the file you should add your exports below the PATH= line and the syntax will look like this for each type, http, https, and ftp. (In older versions of Ubuntu you could use all_proxy which I am not sure is still in use and haven't tested for). One you edit for the exports you need, save and exit.
2.) Create your proxy file
As I've mentioned that by default Ubuntu doesn't have proxy settings enabled and this means that there ins't a proxy setting file for apt-get either. You will need to create one and if you are new to Linux, the file be will automatically created when you open a text editor by the name you intend to use for the file.
sudo vim /etc/apt/apt.conf.d/30proxy
Keep in mind that the two digit number before the file name is arbitrary, it can be any number except for ones already in use. If you want to use a number and see what's there you can run this to see what other files are in that directory;
Moving on to editing the file, the syntax is highly specific and I would suggest copying and pasting what I have written below. Short of that, pay close attention to double quotes (" ") and semicolons (;) and be sure to close every curly bracket used. Save the file once done and off to editing sudoers file next.
3.) Update sudoers file
The sudoers file needs to be edited to allow it to not only inherit, but to also keep the environmental variables being passed to it that you specified in /etc/environment. The best way to edit the sudoers file located /etc/sudoers is to use viduso. Keep in mind unlike vi or vim it doesn't require you to type "i" to input and to save you press ctrl+x, agree with "y" and take the default .tmp file that visudo wants to use to update the sudoers file. The section that you be editing is towards the top where it lists "Defaults". There you will add additional lines equal to each environmental variable and here is the syntax for adding the http_proxy example from before;
Defaults env_keep += http_proxy
Once you are done editing we will perform some tests to find out if sudo is inheriting the environmental variables. Run the following two commands and the output should be the same for both, if sudo is missing ant of the grep searches than try to reboot first and if still the same issue than double check your syntax in previous edits.
env | grep proxy
sudo env | grep proxy
Finally, try to run sudo apt-get update or if you have ruby installed sudo gem update and see if the updates run successfully.