ARTIFACTORY: Why the URL to file path on General tab for an Artifact is different from Custom Base URL
Overview:
Once the file is uploaded to any repository on Artifactory, the URL to the file path is expected to show the complete URL of the file deployed as shown in the screenshot below.
In certain cases when using a Reverse Proxy like Nginx or Apache, this “URL to file path” can be different from the Custom Base URL configured under the Administration module under General | Settings.
How to overcome this behaviour?
Usually, this occurs because of the X-JFrog-Override-Base-Url headers on the reverse proxy configuration file
Nginx:
proxy_set_header X-JFrog-Override-Base-Url $http_x_forwarded_proto://$host:$server_port;
Apache:
RequestHeader set X-JFrog-Override-Base-Url %{my_scheme}e://<servername>:%{my_server_port}e
As the server port is explicitly used on the X-JFrog-Override-Base-Url headers, the URL to the file path can also get updated with the ports used on the reverse proxy.
Hence, to overcome this behavior, update the X-JFrog-Override-Base-Url headers with the same url configured on the Custom Base URL as shown below
Example:
If Custom Base URL is configured with “https://devartifactory.com”, then, update the X-JFrog-Override-Base-Url for Nginx and Apache configurations as shown below
Nginx:
proxy_set_header X-JFrog-Override-Base-Url https://devartifactory.com;
Apache:
RequestHeader set X-JFrog-Override-Base-Url https://devartifactory.com
Ingress:
If you are using Ingress, it is possible to add the proxy_set_header for “X-JFrog-Override-Base-Url” under the annotation section as shown below.
ingress: enabled: true defaultBackend: enabled: false hosts: - myhost.example.com annotations: ingress.kubernetes.io/force-ssl-redirect: "true" ingress.kubernetes.io/proxy-body-size: "0" ingress.kubernetes.io/proxy-read-timeout: "600" ingress.kubernetes.io/proxy-send-timeout: "600" kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/configuration-snippet: | proxy_set_header X-JFrog-Override-Base-Url https://<artifactory-domain>; nginx.ingress.kubernetes.io/proxy-body-size: "0" tls: - hosts: - "myhost.example.com"
Reference article:
https://jfrog.com/help/r/jfrog-installation-setup-documentation/security-related-issues#Using%20Ingress%20Annotations