Set Up an Apache Server using HTTP

JFrog Artifactory Documentation


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

Set a PassReverse Directive on Apache

<VirtualHost *:80>
    ServerAlias *
    ServerAdmin server@admin

    ## Application specific logs
    ## ErrorLog ${APACHE_LOG_DIR}/
    ## CustomLog ${APACHE_LOG_DIR}/ 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://{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/