diff --git a/src/main/java/com/ctrip/zeus/service/build/conf/LocationConf.java b/src/main/java/com/ctrip/zeus/service/build/conf/LocationConf.java index 9143f520..89ce0496 100644 --- a/src/main/java/com/ctrip/zeus/service/build/conf/LocationConf.java +++ b/src/main/java/com/ctrip/zeus/service/build/conf/LocationConf.java @@ -6,6 +6,7 @@ import com.ctrip.zeus.model.entity.Slb; import com.ctrip.zeus.model.entity.VirtualServer; import com.ctrip.zeus.service.model.PathRewriteParser; import com.ctrip.zeus.util.AssertUtils; +import com.netflix.config.DynamicBooleanProperty; import com.netflix.config.DynamicPropertyFactory; import com.netflix.config.DynamicStringProperty; @@ -22,6 +23,9 @@ public class LocationConf { private static DynamicStringProperty xforwardedforWhileList = DynamicPropertyFactory.getInstance().getStringProperty("x-forwarded-for.white.list", "172\\..*|192\\.168.*|10\\..*"); private static DynamicStringProperty errorPageWhileList = DynamicPropertyFactory.getInstance().getStringProperty("errorPage.white.list", null); private static DynamicStringProperty proxyTimeoutList = DynamicPropertyFactory.getInstance().getStringProperty("proxy.read-timeout.list", null); + private static DynamicStringProperty errorPage_404 = DynamicPropertyFactory.getInstance().getStringProperty("errorPage.404.url", null);//"http://slberrorpages.ctripcorp.com/slberrorpages/404.htm"); + private static DynamicStringProperty errorPage_500 = DynamicPropertyFactory.getInstance().getStringProperty("errorPage.500.url", null);//"http://slberrorpages.ctripcorp.com/slberrorpages/500.htm"); + private static DynamicBooleanProperty errorPageEnable = DynamicPropertyFactory.getInstance().getBooleanProperty("errorPage.enable", false);//"http://slberrorpages.ctripcorp.com/slberrorpages/500.htm"); public static String generate(Slb slb, VirtualServer vs, Group group, String upstreamName)throws Exception { StringBuilder b = new StringBuilder(1024); @@ -167,6 +171,9 @@ public class LocationConf { .append("add_header Bastion $cookie_bastion;\n}\n"); } private static void addErrorPageConfig(StringBuilder sb,Long groupId){ + if (!errorPageEnable.get()||errorPage_404.get()==null || errorPage_500.get() == null){ + return; + } String list = errorPageWhileList.get(); if (list == null){ return; diff --git a/src/main/java/com/ctrip/zeus/service/build/conf/ServerConf.java b/src/main/java/com/ctrip/zeus/service/build/conf/ServerConf.java index 20264d4d..cd40525f 100644 --- a/src/main/java/com/ctrip/zeus/service/build/conf/ServerConf.java +++ b/src/main/java/com/ctrip/zeus/service/build/conf/ServerConf.java @@ -7,6 +7,7 @@ import com.ctrip.zeus.model.entity.Slb; import com.ctrip.zeus.model.entity.VirtualServer; import com.ctrip.zeus.util.AssertUtils; import com.ctrip.zeus.util.StringFormat; +import com.netflix.config.DynamicBooleanProperty; import com.netflix.config.DynamicPropertyFactory; import com.netflix.config.DynamicStringProperty; import org.slf4j.Logger; @@ -21,8 +22,9 @@ import java.util.List; public class ServerConf { private static final Logger LOGGER = LoggerFactory.getLogger(ServerConf.class); private static DynamicStringProperty allowSSL = DynamicPropertyFactory.getInstance().getStringProperty("virtual-server-id.ssl", ""); - private static DynamicStringProperty errorPage_404 = DynamicPropertyFactory.getInstance().getStringProperty("errorPage.404.url", "http://slberrorpages.ctripcorp.com/slberrorpages/404.htm"); - private static DynamicStringProperty errorPage_500 = DynamicPropertyFactory.getInstance().getStringProperty("errorPage.500.url", "http://slberrorpages.ctripcorp.com/slberrorpages/500.htm"); + private static DynamicStringProperty errorPage_404 = DynamicPropertyFactory.getInstance().getStringProperty("errorPage.404.url", null);//"http://slberrorpages.ctripcorp.com/slberrorpages/404.htm"); + private static DynamicStringProperty errorPage_500 = DynamicPropertyFactory.getInstance().getStringProperty("errorPage.500.url", null);//"http://slberrorpages.ctripcorp.com/slberrorpages/500.htm"); + private static DynamicBooleanProperty errorPageEnable = DynamicPropertyFactory.getInstance().getBooleanProperty("errorPage.enable", false);//"http://slberrorpages.ctripcorp.com/slberrorpages/500.htm"); public static final String SSL_PATH = "/data/nginx/ssl/"; public static String generate(Slb slb, VirtualServer vs, List groups) throws Exception{ @@ -75,6 +77,9 @@ public class ServerConf { return res; } private static void addErrorPage(StringBuilder sb){ + if (!errorPageEnable.get()||errorPage_404.get()==null || errorPage_500.get() == null){ + return; + } sb.append("error_page 400 404 = /404page;\n"); sb.append("error_page 500 = /500page;\n"); sb.append("location /404page {\n");