gitlabgitlab-7

Gitlab: how to change domain on the old uploaded assets?


I have changed the domain on my gitlab installation from ABC to XYZ according to the procedure explained here:

How to change URL of a working GitLab install?

The problem is, that old uploaded assets (images that were added to issues in projects), still point to the old ABC domain:

https://ABC/uploads/...

The Site is using SSL. The old ABC SSL certificate is no longer valid. Hence, those assets generate "net::ERR_INSECURE_RESPONSE" in the browser and are not shown.

Is there a way to update those assets to use the new domain name? I have tried:

bundle exec rake assets:precompile RAILS_ENV=production

to no avail.

Newly uploaded images on the new domain show correctly.


Solution

  • Gitlab: how to change domain on the old uploaded assets?

    For what I could understand, older versions of Gitlab store the absolute path of the attached files in the issue description. So even if you reconfigure Gitlab, the URLs in the issue descriptions will still be pointing to the old domain.

    After you reconfigure your Gitlab with the new domain you could:

    1: edit the posts manually

    If you don't have a lot of embeded files you can just edit every issue and save. Any edit will trigger the link update.

    2: edit the database

    sudo -u gitlab-psql /opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql/ gitlabhq_production
    update issues set description_html = replace(description_html, 'old.domain', 'new.domain');
    

    3: update Gitlab then clear the cache

    Newer versions of Gitlab store a relative path to the uploaded files instead of the absolute one

    apt-get install gitlab
    sudo gitlab-rake cache:clear
    sudo gitlab-ctl reconfigure
    

    References

    https://gitlab.com/gitlab-org/gitlab-ce/issues/32789

    https://gitlab.com/gitlab-org/gitlab-ce/issues/2476

    How to change URL of a working GitLab install?

    direct access to to gitlab database