Http proxy setting in linux

Использование прокси

В этой статье содержится описание настроек прокси-соединений для различных программ.

Глобальные настройки

Для того, чтобы настроить прокси в Ubuntu откройте Системные параметры, перейдите в пункт Сеть. Выберите пункт Сетевая прокси-служба. Смените метод на Вручную и введите ваши настройки прокси. Минус такой настройки в том, что в случае, если у Вас прокси с авторизацией по логину и паролю, то указать эти данные невозможно, и прокси не будет работать.

Настроить прокси на системном уровне можно и через конфигурационные файлы (True UNIX-way). Для этого нужно открыть на редактирования с правами root файл /etc/environment (например sudo nano /etc/environment). В конец файла добавим строки:

https_proxy="https://user:pass@proxy:port/" http_proxy="http://user:pass@proxy:port/" ftp_proxy="ftp://user:pass@proxy:port/" socks_proxy="socks://user:pass@proxy:port/"

Если прокси без авторизации, то строки должны быть вида:

Для применения настроек придется пере-загрузиться, изменения в файле /etc/environment вступили в силу при запуске процесса init — родителя всех процессов в системе и именно от него все дочерние процессы унаследуют настройки прокси в переменных окружения.

Как правила глобальной насторойки прокси достаточно для того что бы все остальные приложения работали через прокси без необходимости настраивать прокси внутри приложения. Однако некоторые приложения не умеют работать с глобальными настройками или им нужны особенные настройки.

Firefox

Firefox умеет использовать как глобальные настройки, так и свои собственные. Для того чтобы назначить ему прокси, откройте его окно настроек, перейдите на вкладку Дополнительно, далее на вкладку Сеть и нажмите на кнопку Настроить напротив надписи Настройка параметров соединения Firefox с Интернетом. Важное отличие от других программ — он умеет использовать NTLM аутентификацию (используется на Microsoft Internet Security and Acceleration Server).

Chromium-browser

Также может использовать глобальные настройки и имеет свои. Для того чтобы назначить ему прокси персонально, откройте файл /etc/chromium-browser/default и допишите следующие строки:

CHROMIUM_FLAGS="-proxy-server=адрес:порт"

APT

В новых версиях умеет работать с глобальными настройками, но в более старых мог работать только с персональными настройками. Сообщенные настройки: в файле /etc/apt/apt.conf нужно указать:

Acquire::http::proxy "http://логин:пароль@ip_прокси:порт_прокси/"; Acquire::https::proxy "http://логин:пароль@ip_прокси:порт_прокси/"; Acquire::ftp::proxy "http://логин:пароль@ip_прокси:порт_прокси/"; Acquire::socks::proxy "http://логин:пароль@ip_прокси:порт_прокси/"; Acquire. Proxy "true";

Если сервер без авторизации, то логин:пароль@ нужно убрать.

Bash

Само собой настройка через /etc/environment (описано выше в разделе глобальных настроек) будет работать для всех программ запущенных из терминала. Если вы хотите указать настройки персонально для запускаемой программы, то перед ее запуском нужно выполнить:

export http_proxy='http://логин:пароль@ip_прокси:порт_прокси/' export ftp_proxy='http://логин:пароль@ip_прокси:порт_прокси/'

wget

Дописываем в файл /etc/wgetrc :

proxy-user = username proxy-password = password http_proxy = http://xxx.xxx.xxx.xxx:8080/ ftp_proxy = http://xxx.xxx.xxx.xxx:8080/ use_proxy = on

Если прокси без авторизации, то proxy-user и proxy-password нужно убрать

Читайте также:  Node js ide linux

apt-add-repository

Многие компании и университеты блокируют все неизвестные порты наружу. Обычно блокируется и порт 11371, используемый утилитой apt-add-repository для добавления репозиториев. Есть простое решение, как получать ключи репозиториев через 80-ый порт, который используется для доступа к web-страницам и чаще всего не блокируется.

Редактируем файл /usr/lib/python2.6/dist-packages/softwareproperties/ppa.py (нужны привилегии root, вместо /usr/lib/python2.6 может быть версия 2.7). Ищем фразу keyserver.ubuntu.com , заменяем

В версии 16.04 достаточно иметь настроенной переменную окружения

https_proxy="https://user:pass@proxy:port/"
  • Сайт
  • Об Ubuntu
  • Скачать Ubuntu
  • Семейство Ubuntu
  • Новости
  • Форум
  • Помощь
  • Правила
  • Документация
  • Пользовательская документация
  • Официальная документация
  • Семейство Ubuntu
  • Материалы для загрузки
  • Совместимость с оборудованием
  • RSS лента
  • Сообщество
  • Наши проекты
  • Местные сообщества
  • Перевод Ubuntu
  • Тестирование
  • RSS лента

© 2018 Ubuntu-ru — Русскоязычное сообщество Ubuntu Linux.
© 2012 Canonical Ltd. Ubuntu и Canonical являются зарегистрированными торговыми знаками Canonical Ltd.

Источник

How to set up proxy using http_proxy & https_proxy environment variable in Linux?

In this article I will share the steps to set up proxy server using https_proxy and https_proxy environment variable.

How to set up proxy using http_proxy & https_proxy environment variable in Linux?

What is Proxy Server?

A proxy server is a dedicated computer or a software system running on a computer that acts as an intermediary between an endpoint device, such as a computer, and another server from which a user or client is requesting a service. The proxy server may exist in the same machine as a firewall server or it may be on a separate server, which forwards requests through the firewall.

Check current proxy configuration status (https_proxy/https_proxy)

This variable will show if there is a proxy server configured on the system:

# echo $http_proxy # echo $https_proxy

If these variables are empty it would mean that there are no proxy servers configured on the system level.

Set up proxy server using http_proxy environment variable

The http_proxy and https_proxy environment variable is used to specify proxy settings to client programs such as curl and wget .

Set up proxy without username and password

Execute the below command with valid SERVER_IP and PORT on the terminal. This will enable proxy configuration for the current session but these values will not be persistent across reboot.

# export http_proxy=http://SERVER:PORT/

Set up proxy with username and password

You can modify the earlier command to add the username and password value assuming a valid authentication is required to enable the proxy server configuration. But again this command will also enable proxy server for the current session only and will not be persistent across reboots.

# export http_proxy=http://USERNAME:PASSWORD@SERVER:PORT/

Set up proxy with domain, username and password

Assuming you are also required to add domain detail while setting up proxy configuration on your system then use the below command

# export http_proxy=http://DOMAIN\\USERNAME:PASSWORD@SERVER:PORT/

Special character (@) handling

With more complex and robust handling of special characters in username or password follow How to setup http or https proxy with special characters in username and password

Читайте также:  Exiting vim in linux

When the username or password uses the @ symbol, add a backslash (\) before the @ — for example:

export http_proxy=http://DOMAIN\\USERN\@ME:PASSWORD@SERVER:PORT
export http_proxy=http://DOMAIN\\USERNAME:P\@SSWORD@SERVER:PORT

Set up proxy permanently using /etc/environment

Now as I have highlighted above the above commands will work only for the current active session but will not be available across reboots. So to make these changes persistent define the environment variables in /etc/environment file:

# echo "http_proxy=http://proxy.example.com:3128/" >> /etc/environment

Set up proxy permanently using /etc/profile.d

For bash and sh users, add the export line given above into a new file called /etc/profile.d/http_proxy.sh file:

# echo "export http_proxy=http://proxy.example.com:3128/" > /etc/profile.d/http_proxy.sh

For csh and tcsh users, use the following command to set the http_proxy variable in a new file called /etc/profile.d/http_proxy.csh file:

# echo "setenv http_proxy http://proxy.example.com:3128/" > /etc/profile.d/http_proxy.csh

The extension of these files determines which shell will read them. The commands are not interchangeable.

Replace http_proxy with https_proxy in the export argument to enable proxy over SSL/TLS. This information will be provided by the Network Team who have provided the proxy server related details.

Lastly I hope the steps from the article to setup proxy using http_proxy and https_proxy environment variable in Linux was helpful. So, let me know your suggestions and feedback using the comment section.

Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

4 thoughts on “How to set up proxy using http_proxy & https_proxy environment variable in Linux?”

Your example “Set up proxy permanently using /etc/environment” should use a double redirect (>>) to APPEND instead of a single redirect (>) to OVERWRITE the environment file. If someone were to copy/paste your example, they would overwrite any other existing environment settings in their /etc/environment file! # echo “http_proxy=http://proxy.example.com:3128/” >> /etc/environment Reply

I would like to set up a proxy in debian10 via environment file.
The username, password, however, includes a comma (,)
How does that affect the phrasing? Reply

Источник

Configure Proxy On Ubuntu – Settings & Options!

configure proxy on ubuntu

Generally Proxies are used in business networks to prevent attacks and unexpected access and intrusions into the internal networks.

A proxy server can act as an intermediary between the client computer and the internet, and allows you to implement Internet access controls like authentication for Internet connection, sharing Internet connections, bandwidth control and content filtering and blocking.

Читайте также:  Linux device driver module

If your home or office network is behind a proxy server, then you will need to setup proxy in order to browse the Internet.

In this tutorial, we will show you several ways to configure proxy settings in Ubuntu desktop.

Setting Up Proxy with Ubuntu Desktop GUI

You can setup the proxy in Ubuntu Desktop by following the below steps:

1. Open System Settings in Ubuntu as shown below:

2. Click on the Network => Network Proxy as shown below:

3. In the Method drop down list, choose Manual, provide proxy server’s hostname or IP address and port number.

4. Click on Apply system wide to apply the changes.

Setting Up Proxy with Ubuntu Desktop Terminal

You can also set proxy settings using environment variables. There are several environment variables available in Linux to setup a proxy for HTTP, HTTPS and FTP.

You can setup proxy for temporary usage and permanent for single and all users.

The basic syntax of setting up proxy as shown below:

Setting Up Permanent Proxy for Single User

You can setup a permanent proxy for a single user by editing the ~/.bashrc file:

First, login to your Ubuntu system with a user that you want to set proxy for.

Next open the terminal interface and edit the ~/.bashrc file as shown below:

Add the following lines at the end of the file that matches with your proxy server:

export http_proxy=username:password@proxy-server-ip:8080
export https_proxy=username:password@proxy-server-ip:8082
export ftp_proxy=username:password@proxy-server-ip:8080
exprot no_proxy=localhost, 127.0.0.1

Save and close the file when you are finished.

Then to activate your new proxy settings for the current session, use the following command:

Setting Up Permanent Proxy for All User

You can also setup Permanent proxy for all users by setting up global variables in /etc/environment file.

To do so, login with root or administrative user and edit the /etc/environment file:

Add the following lines at the end of the file that matches with your proxy server:

http_proxy=»http://username:password@proxy-server-ip:8080/»
https_proxy=»http://username:password@proxy-server-ip:8082/»
ftp_proxy=»http://username:password@proxy-server-ip:8083/»
no_proxy http://username:password@proxy-server-ip:8080/»;
Acquire::https::Proxy «https://username:password@proxy-server-ip:8081/»;

Save and close the file when you are finished. Now, you can install any package in your system.

You can also install the package by specifying your proxy settings with your command as shown below:

‘http://username:password@proxy-server-ip:8080’ apt-get install package-name

Conclusion

In the above guide, we learned how to setup proxy in Ubuntu using several methods. I hope you have now enough knowledge to setup proxy on Ubuntu system.

Recent Posts

  • Forcepoint Next-Gen Firewall Review & Alternatives
  • 7 Best JMX Monitoring Tools
  • Best PostgreSQL Backup Tools
  • Best CSPM Tools
  • Best Cloud Workload Security Platforms
  • Best Automated Browser Testing Tools
  • Event Log Forwarding Guide
  • Best LogMeIn Alternatives
  • Citrix ShareFile Alternatives
  • SQL Server Security Basics
  • Cloud Security Posture Management Guide
  • Cloud Workload Security Guide
  • The Best JBoss Monitoring Tools
  • ITL Guide And Tools
  • 10 Best Enterprise Password Management Solutions

Источник

Оцените статью
Adblock
detector