2

I've tried installing a CentOS 8 server behind a corporate proxy but I can't seem to figure out why it won't let me do any connection commands.

vi /etc/profile.d/proxy.sh
# proxy    settings
MB_PROXY_URL="http://username:[email protected]:3128/"

http_proxy=$MB_PROXY_URL
https_proxy=$MB_PROXY_URL
ftp_proxy=$MB_PROXY_URL
no_proxy="127.0.0.1,localhost,domain.ltd,192.168.0.*"

HTTP_PROXY=$MB_PROXY_URL
HTTPS_PROXY=$MB_PROXY_URL
FTP_PROXY=$MB_PROXY_URL
NO_PROXY="127.0.0.1,localhost,domain.ltd,192.168.0.*"

export http_proxy https_proxy ftp_proxy no_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY NO_PROXY

# then run
source /etc/profile.d/proxy.sh

vi /etc/dnf/dnf.conf
# proxy settings
proxy=http://proxy.domain.ltd:3128/
proxy_username=username
proxy_password=password

vi /etc/wgetrc
# proxy settings
http_proxy    = http://username:[email protected]:3128/
https_proxy    = http://username:[email protected]:3128/
ftp_proxy    = http://username:[email protected]:3128/
no_proxy    = "127.0.0.1,localhost,domain.ltd,192.168.0.*"

I have the exact settings on a CentOS 7 server (except yum instead of dnf) and I am able to connect to do updates or installs.

The error message I receive when running: yum -y update kernel or yum -y update or yum -y upgrade is:

[root@server01 ~]# yum install nano
CentOS-8 - AppStream                                                   106 kB/s | 2.1 kB     00:00    
Failed to download metadata for repo 'AppStream'
Error: Failed to download metadata for repo 'AppStream'

I have searched around for a solution to proxies, and to the AppStream but nothing seems to work.

When I run the commands verbose, I get the HTTP 407 error but I cant seem to find any other areas to add a proxy.

Some things I have tried are:

  • changing the repo from mirror to base
  • changing the repo from http to https
  • disabling the SELINUX
  • stopping the firewall

There doesn't seem to be as much documentation for CentOS 8 but hopefully someone can help!

2 Answers 2

4

Turns out the dnf has changed the way it deals with proxies. If you’re using a basic proxy authentication then you need to specify it:

vi /etc/dnf/dnf.conf
# proxy settings
proxy=http://proxy.domain.ltd:3128/
proxy_username=username
proxy_password=password
proxy_auth_method=basic
0

This solution didn't work for me for whatever reason.

I had to use my older CentOS 7 settings plus the proxy_ user/pass/auth - one or the other would not work and squid proxy always logged "tcp_denied/407" indicating basic HTTP authentication was required.

MRE

Files:

  • /etc/redhat-release:
    Rocky Linux release 8.4 (Green Obsidian)
    
  • /etc/squid/squid.conf:
    auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
    
  • /etc/dnf/dnf.conf:
    [main]
    gpgcheck=1
    installonly_limit=3
    clean_requirements_on_remove=True
    best=True
    skip_if_unavailable=False
    proxy=http://MY_PROXY_USER:MY_PROXY_PASS@MY_PROXY_HOST:MY_PROXY_PORT
    #proxy=http://MY_PROXY_HOST:MY_PROXY_PORT
    proxy_auth_method=basic
    proxy_user=MY_PROXY_USER
    proxy_password=MY_PROXY_PASS
    #sslverify=0
    debuglevel=10
    
  • ~/.curlrc:
    proxy=MY_PROXY_HOST:MY_PROXY_PORT
    proxy-user=MY_PROXY_USER:MY_PROXY_PASS
    

Test:

tail -f /var/log/squid/access.log
dnf clean all && dnf -vv search --showduplicates librepo-
  • This works with and without sslverify=0
  • This works with and without ~/.curlrc settings
  • This only works with all the proxy settings not commented out.

I hope this helps someone.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .