GitLab Web GUI: API is not accessible

I have a fresh install of Gitlab CE via omnibus (12.9.3).

When i log into the platform, which is running behind NGINX reverse proxy i can successfully create projects, issues and users… not a problem.

The issue arises when i try to add a file via the web UI i get the API is not accessible.

I have setup SSH keys for my users
I have an Access Token created
I am currently running the system over HTTP… not HTTPS

I also tried to push to the repo via Smart Git nothing…

Any help would be appreciated.

Hi,

can you share the configuration details of your Nginx reverse proxy. Also, please share a screenshot when you’re adding a file and the error from the browsers dev console.

Cheers,
Michael

Absolutly.

NGIX Config:

root@DOMAIN:/etc/nginx/conf.d# more gitlab-omnibus-nginx.conf
upstream gitlab-workhorse {
server unix://var/opt/gitlab/gitlab-workhorse/socket fail_timeout=0;
}

server {
listen *:80;
server_name gitlab.DOMAIN.com;
server_tokens off;
root /opt/gitlab/embedded/service/gitlab-rails/public;

client_max_body_size 250m;

access_log /var/log/gitlab/nginx/gitlab_access.log;
error_log /var/log/gitlab/nginx/gitlab_error.log;

Ensure Passenger uses the bundled Ruby version

passenger_ruby /opt/gitlab/embedded/bin/ruby;

Correct the $PATH variable to included packaged executables

passenger_env_var PATH "/opt/gitlab/bin:/opt/gitlab/embedded/bin:/usr/local/bin:/usr/bin:/bin";

Make sure Passenger runs as the correct user and group to

# prevent permission issues
  passenger_user git;
    passenger_group git;

Enable Passenger & keep at least one instance running at all times

passenger_enabled on;
  passenger_min_instances 1;

location ~ ^/[\w.-]+/[\w.-]+/(info/refs|git-upload-pack|git-receive-pack)$ {
# ‘Error’ 418 is a hack to re-use the @gitlab-workhorse block
error_page 418 = @gitlab-workhorse;
return 418;
}

location ~ ^/[\w.-]+/[\w.-]+/repository/archive {
# ‘Error’ 418 is a hack to re-use the @gitlab-workhorse block
error_page 418 = @gitlab-workhorse;
return 418;
}

location ~ ^/api/v3/projects/.*/repository/archive {
# ‘Error’ 418 is a hack to re-use the @gitlab-workhorse block
error_page 418 = @gitlab-workhorse;
return 418;
}

Build artifacts should be submitted to this location

location ~ ^/[\w\.-]+/[\w\.-]+/builds/download {
      client_max_body_size 0;
            # 'Error' 418 is a hack to re-use the @gitlab-workhorse block
                  error_page 418 = @gitlab-workhorse;
                        return 418;
                          }

Build artifacts should be submitted to this location

location ~ /ci/api/v1/builds/[0-9]+/artifacts {
      client_max_body_size 0;
            # 'Error' 418 is a hack to re-use the @gitlab-workhorse block
                  error_page 418 = @gitlab-workhorse;
                        return 418;
                          }

Build artifacts should be submitted to this location

location ~ /api/v4/jobs/[0-9]+/artifacts {
      client_max_body_size 0;
            # 'Error' 418 is a hack to re-use the @gitlab-workhorse block
                  error_page 418 = @gitlab-workhorse;
                        return 418;
                          }

For protocol upgrades from HTTP/1.0 to HTTP/1.1 we need to provide Host header if its missing

if ($http_host = "") {
  # use one of values defined in server_name
      set $http_host_with_default "gitlab.aamcreative.com";
        }

if ($http_host != “”) {
set $http_host_with_default $http_host;
}

location @gitlab-workhorse {

## https://github.com/gitlabhq/gitlabhq/issues/694
    ## Some requests take more than 30 seconds.
        proxy_read_timeout      3600;
            proxy_connect_timeout   300;
                proxy_redirect          off;

# Do not buffer Git HTTP responses
    proxy_buffering off;

proxy_set_header    Host                $http_host_with_default;
    proxy_set_header    X-Real-IP           $remote_addr;
        proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
            proxy_set_header    X-Forwarded-Proto   $scheme;

proxy_pass http://gitlab-workhorse;

## The following settings only work with NGINX 1.7.11 or newer
    #
        ## Pass chunked request bodies to gitlab-workhorse as-is
            # proxy_request_buffering off;
                # proxy_http_version 1.1;
                  }

Enable gzip compression as per rails guide:

## http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
  ## WARNING: If you are using relative urls remove the block below
    ## See config/application.rb under "Relative url support" for the list of
      ## other files that need to be changed for relative url support
        location ~ ^/(assets)/ {
            root /opt/gitlab/embedded/service/gitlab-rails/public;
                gzip_static on; # to serve pre-gzipped version
                    expires max;
                        add_header Cache-Control public;
                          }

error_page 502 /502.html;
}

Screenshots:

To close on this item, it turned out i had the API listening on the wrong port

gitlab_rails[‘internal_api_url’] was set incorrectly

1 Like