diff --git a/.gitignore b/.gitignore
index 91ea81bfc4ebd5633e5c6765862c5b6da97c198d..1eb785451f4904144168fcdf7b941584a9be91d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ config/gitlab.yml
 config/gitlab_ci.yml
 config/initializers/rack_attack.rb
 config/initializers/smtp_settings.rb
+config/initializers/relative_url.rb
 config/resque.yml
 config/unicorn.rb
 config/secrets.yml
diff --git a/CHANGELOG b/CHANGELOG
index ff6d384f7fd2764429cbd3505b69f6ce535ea443..088e31f7d484e73b443654ec38da188eb82b798f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@ v 8.6.0 (unreleased)
 v 8.5.2
   - Fix sidebar overlapping content when screen width was below 1200px
   - Fix error 500 when commenting on a commit
+  - Fix broken icons on installations with relative URL (Artem Sidorenko)
 
 v 8.5.1
   - Fix group projects styles
diff --git a/Rakefile b/Rakefile
index 35b2f05cbb4566b71b34554cf184a9d0bd9d46d6..5dd389d5678e1e7aeb90b4c879d1dbe150b96b40 100755
--- a/Rakefile
+++ b/Rakefile
@@ -4,4 +4,7 @@
 
 require File.expand_path('../config/application', __FILE__)
 
+relative_url_conf = File.expand_path('../config/initializers/relative_url', __FILE__)
+require relative_url_conf if File.exist?("#{relative_url_conf}.rb")
+
 Gitlab::Application.load_tasks
diff --git a/config/application.rb b/config/application.rb
index b905f1a3e9045f14bf622645ac6398f3f79bed15..28684a3e578cf701c3f50241120757bb964a5a24 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -54,14 +54,6 @@ module Gitlab
 
     config.action_view.sanitized_allowed_protocols = %w(smb)
 
-    # Relative URL support
-    # WARNING: We recommend using an FQDN to host GitLab in a root path instead
-    # of using a relative URL.
-    # Documentation: http://doc.gitlab.com/ce/install/relative_url.html
-    # Uncomment and customize the following line to run in a non-root path
-    #
-    # config.relative_url_root = "/gitlab"
-
     config.middleware.use Rack::Attack
 
     # Allow access to GitLab API from other domains
diff --git a/config/initializers/relative_url.rb.sample b/config/initializers/relative_url.rb.sample
new file mode 100644
index 0000000000000000000000000000000000000000..125297d5385eeec13e9a88d245cc128d04b5738d
--- /dev/null
+++ b/config/initializers/relative_url.rb.sample
@@ -0,0 +1,10 @@
+# Relative URL support
+# WARNING: We recommend using an FQDN to host GitLab in a root path instead
+# of using a relative URL.
+# Documentation: http://doc.gitlab.com/ce/install/relative_url.html
+# Copy this file to relative_url.rb and customize it to run in a non-root path
+#
+
+Rails.application.configure do
+  config.relative_url_root = "/gitlab"
+end
diff --git a/doc/install/relative_url.md b/doc/install/relative_url.md
index b341b6311c6e778fec5af27177e64d6c2678cf12..0245febfcd878cbffd1c18dfd610485e2c76df8b 100644
--- a/doc/install/relative_url.md
+++ b/doc/install/relative_url.md
@@ -25,7 +25,7 @@ that points to your GitLab instance.
 The TL;DR list of configuration files that you need to change in order to
 serve GitLab under a relative URL is:
 
-- `/home/git/gitlab/config/application.rb`
+- `/home/git/gitlab/config/initializers/relative_url.rb`
 - `/home/git/gitlab/config/gitlab.yml`
 - `/home/git/gitlab/config/unicorn.rb`
 - `/home/git/gitlab-shell/config.yml`
@@ -66,8 +66,14 @@ Make sure to follow all steps below:
     sudo service gitlab stop
     ```
 
-1.  Edit `/home/git/gitlab/config/application.rb` and uncomment/change the
-    following line:
+1.  Create `/home/git/gitlab/config/initializers/relative_url.rb`
+
+    ```shell
+    cp /home/git/gitlab/config/initializers/relative_url.rb.sample \
+       /home/git/gitlab/config/initializers/relative_url.rb
+    ```
+
+    and change the following line:
 
     ```ruby
     config.relative_url_root = "/gitlab"
@@ -119,8 +125,12 @@ Make sure to follow all steps below:
 
 ### Disable relative URL in GitLab
 
-To disable the relative URL, follow the same steps as above and set up the
-GitLab URL to one that doesn't contain a relative path.
+To disable the relative URL:
+
+1.  Remove `/home/git/gitlab/config/initializers/relative_url.rb`
+
+1.  Follow the same as above starting from 2. and set up the
+    GitLab URL to one that doesn't contain a relative path.
 
 [omnibus-rel]: http://doc.gitlab.com/omnibus/settings/configuration.html#configuring-a-relative-url-for-gitlab "How to setup relative URL in Omnibus GitLab"
 [restart gitlab]: ../administration/restart_gitlab.md#installations-from-source "How to restart GitLab"