diff --git a/pom.xml b/pom.xml
index 5f8836f..3a36075 100644
--- a/pom.xml
+++ b/pom.xml
@@ -142,6 +142,11 @@
querydsl-apt
${querydsl.version}
+
+ org.mitre.dsmiley.httpproxy
+ smiley-http-proxy-servlet
+ 1.12.1
+
diff --git a/src/main/java/com/xydl/cac/config/SolrProxyServletConfiguration.java b/src/main/java/com/xydl/cac/config/SolrProxyServletConfiguration.java
new file mode 100644
index 0000000..d108b19
--- /dev/null
+++ b/src/main/java/com/xydl/cac/config/SolrProxyServletConfiguration.java
@@ -0,0 +1,36 @@
+package com.xydl.cac.config;
+
+import org.mitre.dsmiley.httpproxy.ProxyServlet;
+import org.springframework.boot.context.properties.bind.BindResult;
+import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
+import org.springframework.context.EnvironmentAware;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
+
+import java.util.Properties;
+
+@Configuration
+public class SolrProxyServletConfiguration implements EnvironmentAware {
+
+ @Bean
+ public ServletRegistrationBean servletRegistrationBean() {
+ Properties properties = (Properties) bindResult.get();
+ ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new ProxyServlet(), properties.getProperty("servlet_url"));
+ servletRegistrationBean.addInitParameter(ProxyServlet.P_TARGET_URI, properties.getProperty("target_url"));
+ servletRegistrationBean.addInitParameter(ProxyServlet.P_LOG, properties.getProperty("logging_enabled", "false"));
+ return servletRegistrationBean;
+ }
+
+ private BindResult bindResult;
+
+ @Override
+ public void setEnvironment(Environment environment) {
+ Iterable sources = ConfigurationPropertySources.get(environment);
+ Binder binder = new Binder(sources);
+ BindResult bindResult = binder.bind("proxy.solr", Properties.class);
+ this.bindResult = bindResult;
+ }
+}
diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml
index 9168668..3d58c6a 100644
--- a/src/main/resources/application-dev.yml
+++ b/src/main/resources/application-dev.yml
@@ -24,3 +24,8 @@ spring:
multipart:
max-file-size: 100MB
max-request-size: 100MB
+
+proxy:
+ solr:
+ servlet_url: /prod-api/*
+ target_url: http://127.0.0.1:8082/
diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml
index 7053936..788ac02 100644
--- a/src/main/resources/application-prod.yml
+++ b/src/main/resources/application-prod.yml
@@ -24,3 +24,8 @@ spring:
multipart:
max-file-size: 100MB
max-request-size: 100MB
+
+proxy:
+ solr:
+ servlet_url: /prod-api/*
+ target_url: http://127.0.0.1:8082/