Skip to content

Commit

Permalink
Use proxy FQDN from config file for auth token (#9265)
Browse files Browse the repository at this point in the history
AuthToken appended FQDN is used also for translating autoyast/ks
server FQDN to proxy one. AuthToken thus has to use external FQDN
and not internal pod hostname.

This commit introduce this change and also fix for hairpin problem
as AuthToken hostname was used for internal connection, which must
be localhost (or internal pod hosname) for container scenario.
  • Loading branch information
aaannz authored Sep 24, 2024
1 parent 66c4d18 commit a49ad32
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- store proxy FQDN in the rhn.conf for auth token use
(bsc#1230255)
1 change: 1 addition & 0 deletions containers/proxy-httpd-image/uyuni-configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def insert_under_line(file_path, line_to_match, line_to_insert):
# Hostname of Uyuni, SUSE Manager Server or another proxy
proxy.rhn_parent = {config['server']}
proxy.proxy_fqdn = {config['proxy_fqdn']}
# Destination of all tracebacks, etc.
traceback_mail = {config['email']}
Expand Down
4 changes: 4 additions & 0 deletions proxy/proxy/broker/rhnBroker.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ def __init__(self, req):
socket.herror, socket.timeout):
# hostname probably didn't exist, fine
pass
if not hostname and CFG.has_key('PROXY_FQDN'):
# Not resolvable hostname, check container config
log_debug(2, "Using PROXY_FQDN config %s" % CFG.PROXY_FQDN)
hostname = CFG.PROXY_FQDN
if not hostname:
# okay, that didn't work, let's do a reverse dns lookup on my
# ip address
Expand Down
10 changes: 10 additions & 0 deletions proxy/proxy/rhnShared.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,15 @@ def _connectToParent(self):
# if this request is for an upstream server, use the original query string.
# Otherwise, if it is for the local Squid instance, strip it so that
# Squid will not keep multiple cached copies of the same resource
# Containers notes: when going for local proxy, use localhost as host to avoid
# hairpin problem.
if self.httpProxy not in ['127.0.0.1:8080', 'localhost:8080']:
if 'X-Suse-Auth-Token' in self.req.headers_in:
self.uri += '?%s' % self.req.headers_in['X-Suse-Auth-Token']
elif query:
self.uri += '?%s' % query
else:
host = 'localhost'

log_debug(3, 'Scheme:', scheme)
log_debug(3, 'Host:', host)
Expand Down Expand Up @@ -172,6 +176,12 @@ def _create_connection(self):
'host': host,
'port': port,
}

# Containers notes: when going for local proxy, use localhost as host to avoid
# hairpin problem.
if self.httpProxy in ['127.0.0.1:8080', 'localhost:8080']:
params['host'] = 'localhost'

if CFG.has_key('timeout'):
params['timeout'] = CFG.TIMEOUT
if self.httpProxy:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- set proxy authtoken FQDN based on config file
(bsc#1230255)

0 comments on commit a49ad32

Please sign in to comment.