Setting Up Apache HTTP Server
Using HTTP
Apache HTTP server using AJP Protocol
From Artifactory version 7.0, the AJP connector is not supported.
You can set up Apache HTTP Server as a front end to Artifactory using the HTTP protocol.
Client ----------> HTTPD ----------> Artifactory HTTP HTTP
When running Artifactory with Tomcat, we recommend that you set up Apache to proxy Artifactory via HTTP.
You must configure redirects correctly using the PassReverse directive, and also set the base URL in Artifactory itself so that the UI links show up correctly.
The sample virtual host assumes that Artifactory listens on port 8081 and all other services and UI are available on port 8082.
Ensuring HTTP Redirect Works Correctly
For HTTP redirects to work, you must set a PassReverse directive on Apache, otherwise the underlying container base URL is passed in redirects
In the example below it is set to http://yourdomain.com/
.
Setting a PassReverse Directive on Apache
<VirtualHost *:80> ServerName yourdomain.com ServerAlias *.yourdomain.com ServerAdmin server@admin ## Application specific logs ## ErrorLog ${APACHE_LOG_DIR}/yourdomain.com-error.log ## CustomLog ${APACHE_LOG_DIR}/yourdomain.com-access.log combined AllowEncodedSlashes On RewriteEngine on RewriteCond %{SERVER_PORT} (.*) RewriteRule (.*) - [E=my_server_port:%1] ## NOTE: The 'REQUEST_SCHEME' Header is supported only from apache version 2.4 and above RewriteCond %{REQUEST_SCHEME} (.*) RewriteRule (.*) - [E=my_scheme:%1] RewriteCond %{HTTP_HOST} (.*) RewriteRule (.*) - [E=my_custom_host:%1] RewriteRule ^(/)?$ /ui/ [R,L] RequestHeader set Host %{my_custom_host}e RequestHeader set X-Forwarded-Port %{my_server_port}e ## NOTE: {my_scheme} requires a module which is supported only from apache version 2.4 and above RequestHeader set X-Forwarded-Proto %{my_scheme}e RequestHeader set X-JFrog-Override-Base-Url %{my_scheme}e://yourdomain.com:%{my_server_port}e ProxyPassReverseCookiePath / / ProxyRequests off ProxyPreserveHost on ProxyPass "/artifactory/" http://<artifactory-ip>:8081/artifactory/ connectiontimeout=5 timeout=2400 ProxyPassReverse "/artifactory/" http://<artifactory-ip>:8081/artifactory/ ProxyPass "/" http://<artifactory-ip>:8082/ nocanon connectiontimeout=5 timeout=2400 ProxyPassReverse "/" http://<artifactory-ip>:8082/ </VirtualHost>
Using HTTPS
You can set up Apache with SSL (HTTPS) as a front end to Artifactory using the HTTP protocol.
Client ----------> HTTPD ----------> Artifactory HTTPS HTTP
Setting SSL/TLS on Apache
<VirtualHost *:443> SSLEngine on SSLCertificateFile path/to/yourdomain.com.crt SSLCertificateKeyFile path/to/yourdomain.com.key SSLProxyEngine on ## Additional reverse proxy directives </VirtualHost>
Configuring a Custom Base URL in Artifactory
When using an HTTP proxy, the links produced by Artifactory, as well as certain redirects might contain the wrong port and use http
instead of https
.
Therefore, you must configure a custom base URL as follows:
On the Admin tab select Configuration | General
Custom Base URL
field.Set the Custom Base URL field to the value used to contact Artifactory
For example:
https://yourdomain.com
Please refer to General System Settings for more details about configuring the base URL.