|
@@ -16,6 +16,7 @@ import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
import com.zhongzheng.common.utils.ip.IpUtils;
|
|
|
import com.zhongzheng.modules.course.bo.CourseBusinessQueryBo;
|
|
|
import com.zhongzheng.modules.order.bo.OrderShareMoneyAddBo;
|
|
|
+import com.zhongzheng.modules.system.bo.SysNginxConfigAddBo;
|
|
|
import com.zhongzheng.modules.system.domain.SysPost;
|
|
|
import com.zhongzheng.modules.system.domain.SysUserPost;
|
|
|
import com.zhongzheng.modules.system.domain.SysUserRole;
|
|
@@ -28,6 +29,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.io.BufferedWriter;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileWriter;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -54,4 +58,80 @@ public class SysWebServiceImpl implements ISysWebService {
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean configNginxFile(SysNginxConfigAddBo bo) {
|
|
|
+ String filePath = "/usr/local/nginx/conf/vhost" + "1.txt";
|
|
|
+ FileWriter fw = null;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ File file = new File(filePath);
|
|
|
+ if (!file.exists())
|
|
|
+ {
|
|
|
+ file.createNewFile();
|
|
|
+ }
|
|
|
+ fw = new FileWriter(filePath);
|
|
|
+ BufferedWriter bw=new BufferedWriter(fw);
|
|
|
+ bw.write("hello\n");
|
|
|
+ bw.write("world\n");
|
|
|
+ bw.close();
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ fw.close();
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String makeConfigTxt(Integer plat,String host){
|
|
|
+ String filePath = null;
|
|
|
+ if(plat==1){
|
|
|
+ filePath = "/www/public/pc";
|
|
|
+ }
|
|
|
+ else if(plat==2){
|
|
|
+ filePath = "/www/public/h5";
|
|
|
+ }
|
|
|
+ else if(plat==3){
|
|
|
+ filePath = "/www/public/live";
|
|
|
+ }
|
|
|
+ String configParam = " server {\n" +
|
|
|
+ " listen 80; # 同时支持HTTP\n" +
|
|
|
+ " listen 443 ssl; # 添加HTTPS支持\n" +
|
|
|
+ " server_name %s;\n" +
|
|
|
+ " root %s;\n" +
|
|
|
+ " if ($scheme = http ) {\n" +
|
|
|
+ "\treturn 301 https://$host$request_uri;\n" +
|
|
|
+ " }\n" +
|
|
|
+ "\n" +
|
|
|
+ " #SSL配置\n" +
|
|
|
+ " ssl_certificate /mydata/nginx/ssl/gdzzkj.net.pem; # 配置证书\n" +
|
|
|
+ " ssl_certificate_key /mydata/nginx/ssl/gdzzkj.net.key; # 配置证书私钥\n" +
|
|
|
+ " ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # 配置SSL协议版本 # 配置SSL加密算法\n" +
|
|
|
+ " ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;\n" +
|
|
|
+ " ssl_prefer_server_ciphers on; # 优先采取服务器算法\n" +
|
|
|
+ " ssl_session_cache shared:SSL:10m; # 配置共享会话缓存大小\n" +
|
|
|
+ " ssl_session_timeout 10m; # 配置会话超时时间\n" +
|
|
|
+ "\n" +
|
|
|
+ "\n" +
|
|
|
+ " index index.html index.htm;\n" +
|
|
|
+ "\n" +
|
|
|
+ " location / {\n" +
|
|
|
+ " try_files $uri $uri/ /index.html?$args;\n" +
|
|
|
+ " }\n" +
|
|
|
+ "}\n";
|
|
|
+ String param = String.format(configParam, host, filePath);
|
|
|
+ return param;
|
|
|
+ }
|
|
|
}
|