当前位置: 首页 > news >正文

网站开发国内外研究背景如何做网站泛目录解析

网站开发国内外研究背景,如何做网站泛目录解析,国人经典wordpress主题liveo,网站建设中联系我们怎么写问题:客户的服务都是内网的,不能直接访问外网;访问外网的话需要走kong网关才能出去。 会话存档官网说可以使用socket5、http方式拉取会话存档;我这边尝试了直接使用kong网关的ip和端口配置进去,是访问不了的 我后面就…

问题:客户的服务都是内网的,不能直接访问外网;访问外网的话需要走kong网关才能出去。

会话存档官网说可以使用socket5http方式拉取会话存档;我这边尝试了直接使用kong网关的ip和端口配置进去,是访问不了的

我后面就又尝试了使用nginxsquid 做正向代理的方式使用http方式访问,也是没有成功;这两种做代理服务器为什么不能成功,没有理解;有知道的朋友可以告诉我一下,有成功使用这两个做代理服务器拉取消息成功的朋友可以分享下经验。

搞一个socket5的代理服务器是可以成功,我没有试过,但是问过踩过坑的人说这种方式可行。

如果懒得麻烦再搭一个代理服务器,那就可以自己动手写一个简单的代理服务器搞定它。

大概的交互流程如下:
在这里插入图片描述

下面是全部的代码,拷过去,调一调应该就能用了

ForwardProxyApplication

import xxx.ProxyService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;import javax.annotation.Resource;@SpringBootApplication
public class ForwardProxyApplication implements CommandLineRunner {@Resourceprivate ProxyService proxyService;public static void main(String[] args) {SpringApplication.run(ForwardProxyApplication.class, args);}@Overridepublic void run(String... args) throws Exception {proxyService.start(args);}
}

ProxyConfig

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;@Configuration
public class ProxyConfig {@Value("${socket.port}")public Integer socketPort;@Value("${proxy.host}")public String proxyHost;@Value("${proxy.port}")public Integer proxyPort;
}

ProxyService

import xxx.config.ProxyConfig;
import xxx.thread.ProxyHandleThread;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;import javax.annotation.Resource;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.Objects;@Service
public class ProxyService {private static final Logger logger = LoggerFactory.getLogger(ProxyService.class);@Resourceprivate ProxyConfig proxyConfig;public void start(String[] args) {ServerSocket ss = null;try {ss = new ServerSocket(proxyConfig.socketPort);logger.info("Server running at http://0.0.0.0:{}", proxyConfig.socketPort);} catch (IOException e1) {e1.printStackTrace();}while (true) {try {assert ss != null;Socket socket = ss.accept();socket.setSoTimeout(1000 * 60);String line = "";InputStream is = socket.getInputStream();String tempHost = "", host;int port = 80;String type = null;OutputStream os = socket.getOutputStream();BufferedReader br = new BufferedReader(new InputStreamReader(is));int temp = 1;StringBuilder sb = new StringBuilder();while ((line = br.readLine()) != null) {logger.info(line + "-----------------");if (temp == 1) {  type = line.split(" ")[0];if (type == null) continue;}temp++;String[] s1 = line.split(": ");if (line.isEmpty()) {break;}for (int i = 0; i < s1.length; i++) {if (s1[i].equalsIgnoreCase("host")) {tempHost = s1[i + 1];}}sb.append(line).append("\r\n");line = null;}sb.append("\r\n"); if (tempHost.split(":").length > 1) {port = Integer.parseInt(tempHost.split(":")[1]);}host = tempHost.split(":")[0];Socket proxySocket = null;if (host != null && !host.equals("")) {// todo 这里最重要的host = proxyConfig.proxyHost;port = proxyConfig.proxyPort;proxySocket = new Socket(host, port);proxySocket.setSoTimeout(1000 * 60);OutputStream proxyOs = proxySocket.getOutputStream();InputStream proxyIs = proxySocket.getInputStream();if (Objects.requireNonNull(type).equalsIgnoreCase("connect")) {  os.write("HTTP/1.1 200 Connection Established\r\n\r\n".getBytes());os.flush();} else {proxyOs.write(sb.toString().getBytes(StandardCharsets.UTF_8));proxyOs.flush();}new ProxyHandleThread(is, proxyOs).start(); //监听客户端传来消息并转发给服务器new ProxyHandleThread(proxyIs, os).start(); //监听服务器传来消息并转发给客户端}} catch (IOException e) {e.printStackTrace();}}}
}

ProxyHandleThread

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.SocketTimeoutException;public class ProxyHandleThread extends Thread {private final InputStream input;private final OutputStream output;public ProxyHandleThread(InputStream input, OutputStream output) {this.input = input;this.output = output;}@Overridepublic void run() {try {BufferedInputStream bis = new BufferedInputStream(input);byte[] buffer = new byte[1024];int length = -1;while ((length = bis.read(buffer)) != -1) {output.write(buffer, 0, length);length = -1;}output.flush();try {Thread.sleep(5000);     //不能执行完了,就把线程关掉,不然双方交互的数据还没有处理完,这里写了个睡眠 5s,可以酌情考虑} catch (InterruptedException e) {e.printStackTrace();}} catch (SocketTimeoutException e) {try {input.close();output.close();} catch (IOException e1) {e1.printStackTrace();}} catch (IOException e) {e.printStackTrace();} finally {try {input.close();output.close();} catch (IOException e) {e.printStackTrace();}}}
}

没有搞定的,可以加好友一起聊聊,请备注csdn加我的
在这里插入图片描述

感谢 https://blog.csdn.net/jumprn/article/details/90173852

http://www.yayakq.cn/news/394263/

相关文章:

  • 网站营销推广策划书建立网站的风险
  • 承接各类网站建设wordpress修改首页文章样式
  • 蓝色管理系统网站模版昆明做网站的公司有哪些
  • 美食网站开发现状espcms易思企业网站管理系统
  • 360浏览器直接进入网站温州市建筑业联合会
  • 国外metro风格网站模板网站服务内容有哪些
  • 中山营销型网站设计网站建设域名的选取有讲究
  • 做网站是做完给钱还是指数运算公式大全
  • 专业网站开发制作文字变形logo设计生成器
  • 网站后台打开很慢网站开发中系统部署与维护要求
  • 网站建设与维护招聘条件男男做的视频网站好
  • python网页版运行器建筑优化公司排名
  • 广州外贸型网站长春师范大学
  • 南宁软件优化网站建设莱州市双语网站
  • 对比色的网站鞍山信息港招聘信息网
  • 凡科手机网站设置问题公司网站开发类属什么费用
  • php钓鱼网站怎么做视频教程如何查看网站的浏览量
  • 网站备案核验照片背景外国做动漫图片的网站叫什么名字
  • 站长统计幸福宝宝官方青岛seo整站优化
  • 怎样做建网站做淘客建模外包网站
  • 上海网站高端利用微博做网站推广
  • 做移动网站优化首页软深圳做电商平台网站
  • 制作网站多少钱wordpress网速卡
  • 网站开发主要职责中卫网站推广服务
  • 湖南平台网站建设公司wordpress手册插件
  • 自适应网站好建们青岛做网站公司电话
  • 武进网站建设方案wordpress图文主题
  • 建设工程 法律 网站广州网站开发创意设计
  • 请别人做网站如何交付如何购买域名和空间
  • 网站流量的重要性那几个网站可以做h5