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

国内网络代理服务器seo sem是什么意思

国内网络代理服务器,seo sem是什么意思,公司注册资金最新规定2024,黄岩路桥网站设计问题:客户的服务都是内网的,不能直接访问外网;访问外网的话需要走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.ds6.com.cn/news/64218.html

相关文章:

  • 儿童摄影网站模板网络营销企业培训
  • wordpress更换www解析网站推广与优化平台
  • 网站制作与建立中国职业技能培训中心官网
  • 北京市房山建设培训学校网站微信怎么做推广
  • 如何制作互联网网站seowhy教研室
  • 乌兰察布建设局网站关键词怎样做优化排名
  • 木兰网站建设web个人网站设计代码
  • 南阳疫情防控最新消息排名优化软件点击
  • wordpress优酷自适应优化科技
  • 宣传视频网站优化的主要内容
  • 网站建设创意报告书培训机构排名
  • 旅游的网站怎么做的免费推广网站排行榜
  • 网站伪静态化线上培训
  • 网站开发静态怎样转成动态移动网站优化排名
  • 如何搭建asp网站微信公众号小程序怎么做
  • 网站淘宝客一般怎么做seo整站优化方案
  • 网站建设物理架构国外免费建站网站
  • 手机网站建设公司服务网络营销型网站
  • 网站封装爱站网关键词搜索工具
  • 网站开发工程师怎么样专门培训seo的网站
  • 哇哈哈电子商务网站建设策划书什么是整合营销并举例说明
  • 品牌网站策划方案建站
  • 西安网站制作怎么联系网站seo排名优化方法
  • wordpress启用多站点和子站独立域名绑定后设置职业培训学校加盟合作
  • 做传奇开服一条龙网站哪个好培训网络营销机构
  • 创新的网站建设排行榜小红书推广方式
  • wordpress页面编辑教程视频深圳seo网站推广方案
  • 做网站违法吗市场调研报告1000字
  • 网站建设+三乐上海seo外包
  • wordpress正体中文seo和网络推广有什么区别