'Is there a way I can retrieve the external base url of the Airflow Server via python?

I will want to provide a direct access to the log file. However, client will be accessing via external IP. So i will like to see if there's any way i can print out the external base url in order for my client to access directly to the log.



Solution 1:[1]

If you can access shell via SSH, you can curl to IP checking website like curl ifconfig.co.

In Python, you can achieve the same thing with requests library.

import requests
res = requests.get("http://ifconfig.co/ip")
print(res.text.strip())

For Airflow, you can write the above script as a function and call it using PythonOperator to execute it.

However, if the Airflow is configured behind a web proxy, like nginx, it may prevent directly access via IP address from the forwarding rule.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1