Redirect root URL to sdc1

Change-Id: I792cf2bfbb2f8f1e891d30048ff63acefac3604e
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Issue-ID: SDC-3877
diff --git a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_7_create_jetty_modules.rb b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_7_create_jetty_modules.rb
index 0a1527f..fb70924 100644
--- a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_7_create_jetty_modules.rb
+++ b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_7_create_jetty_modules.rb
@@ -7,7 +7,7 @@
 end
 
 execute "create-jetty-modules" do
-  command "java -jar #{ENV['JETTY_HOME']}/start.jar --add-to-start=deploy && java -jar #{ENV['JETTY_HOME']}/start.jar --create-startd --add-to-start=http,https,console-capture,setuid"
+  command "java -jar #{ENV['JETTY_HOME']}/start.jar --add-to-start=deploy && java -jar #{ENV['JETTY_HOME']}/start.jar --create-startd --add-to-start=http,https,console-capture,setuid,rewrite"
   cwd "#{ENV['JETTY_BASE']}"
   action :run
 end
@@ -24,7 +24,6 @@
     })
 end
 
-
 template "https-ini" do
    path "#{ENV['JETTY_BASE']}/start.d/https.ini"
    source "https-ini.erb"
@@ -34,6 +33,13 @@
    variables :https_port => "#{node['FE'][:https_port]}"
 end
 
+template "jetty-rewrite" do
+  path "#{ENV['JETTY_BASE']}/etc/rewrite-root-to-sdc1.xml"
+  source "FE-jetty-rewrite.yaml.erb"
+  owner "#{ENV['JETTY_USER']}"
+  group "#{ENV['JETTY_GROUP']}"
+  mode "0644"
+end
 
 template "ssl-ini" do
    path "#{ENV['JETTY_BASE']}/start.d/ssl.ini"
diff --git a/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/templates/default/FE-jetty-rewrite.yaml.erb b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/templates/default/FE-jetty-rewrite.yaml.erb
new file mode 100644
index 0000000..e0862a5
--- /dev/null
+++ b/catalog-fe/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/templates/default/FE-jetty-rewrite.yaml.erb
@@ -0,0 +1,19 @@
+<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
+<Configure id="Server" class="org.eclipse.jetty.server.Server">
+  <Ref refid="Rewrite">
+    <Call name="addRule">
+      <Arg>
+        <New class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">
+          <Set name="pattern" type="String"/>
+          <Set name="location">/sdc1</Set>
+        </New>
+      </Arg>
+    </Call>
+  </Ref>
+  <!-- ===================== -->
+  <!-- DefaultHandler config -->
+  <!-- ===================== -->
+  <Ref id="DefaultHandler">
+    <Set name="showContexts">false</Set>
+  </Ref>
+</Configure>
diff --git a/catalog-fe/sdc-frontend/startup.sh b/catalog-fe/sdc-frontend/startup.sh
index 5a1dd27..7597699 100644
--- a/catalog-fe/sdc-frontend/startup.sh
+++ b/catalog-fe/sdc-frontend/startup.sh
@@ -14,5 +14,6 @@
 chef-solo -c solo.rb -E ${ENVNAME}
 
 cd $JETTY_HOME
+echo "etc/rewrite-root-to-sdc1.xml" >> $JETTY_HOME/start.d/rewrite.ini
 
 java $JAVA_OPTIONS -jar "${JETTY_HOME}/start.jar"