What is the recommended Nginx reverse proxy configuration for Artifactory 7.x and above?

Yonatan Brand
2020-02-09 12:07

In Artifactory 7.x there were a few changes regarding the Nginx reverse proxy configuration. 
The correct snippet should now include the following: (make sure to change the colored fields according to your server)

###########################################################
## this configuration was generated by JFrog Artifactory ##
###########################################################

## server configuration
server {
    listen 80 ;
    server_name <SERVER_NAME>;
    if ($http_x_forwarded_proto = '') {
        set $http_x_forwarded_proto  $scheme;
    }
    ## Application specific logs
    ## access_log /var/log/nginx/<SERVER_NAME>-access.log timing;
    ## error_log /var/log/nginx/<SERVER_NAME>-error.log;
    rewrite ^/$ /ui/ redirect;
    rewrite ^/ui$ /ui/ redirect;
    proxy_buffer_size          128k;
    proxy_buffers              4 256k;
    proxy_busy_buffers_size    256k; 
    chunked_transfer_encoding on;
    client_max_body_size 0;
    location / {
    proxy_read_timeout  2400s;
    proxy_pass_header   Server;
    proxy_cookie_path   ~*^/.* /;
    proxy_pass          http://<SERVER_IP>:8082;
    proxy_set_header    X-JFrog-Override-Base-Url $http_x_forwarded_proto://$host:$server_port;
    proxy_set_header    X-Forwarded-Port  $server_port;
    proxy_set_header    X-Forwarded-Proto $http_x_forwarded_proto;
    proxy_set_header    Host              $http_host;
    proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;

        location ~ ^/artifactory/ {
            proxy_pass    http://<SERVER_IP>:8082;
        }
    }
}