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

专业网站开发价格南京广告宣传公司seo

专业网站开发价格,南京广告宣传公司seo,seo推广哪家公司好,旅游网站建设的相关报价问题:客户的服务都是内网的,不能直接访问外网;访问外网的话需要走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.hkea.cn/news/892699/

相关文章:

  • 百度推广网站建设费百度搜索引擎的网址是多少
  • php 手机网站 上传图片定制网站建设
  • 关于网站建设的问题百度关键词分析
  • 登录官方网站装修公司网络推广方案
  • 设计网站官网入口网站搜索优化方法
  • 网站优化qq群山东做网站
  • wordpress icomoon太原seo快速排名
  • 中华建设杂志网站记者数据指数
  • 网站开发测试情况南召seo快速排名价格
  • 上海仓储公司小红书seo优化
  • 南京建设公司网站网络营销整合推广
  • wordpress更改语言沈阳seo优化
  • wordpress免费网站世界大学排名
  • 做网站的属于什么专业?百度爱采购竞价推广
  • 网站建设一年多少恰东莞网站到首页排名
  • 新企业网站应该怎么做SEO优化广告联盟有哪些
  • 手机app开发网站建设软文推广文章案例
  • 网站自然排名百度经验官网登录
  • dz网站模板沧州网站优化公司
  • 桂林论坛天涯社区培训行业seo整站优化
  • 做伊瑞尔竞技场的网站搜索引擎简称seo
  • 46云虚拟主机股票发行ipo和seo是什么意思
  • 新泰做网站菏泽seo
  • 网站建设排名东莞seo收费
  • 做网站前后端的发布流程自己如何制作网站
  • 网站营销与推广策略百度一下官网首页百度
  • 网站建设张世勇100个免费推广b站
  • 网络营销的常用工具百度关键词优化点击 教程
  • 公司网站要怎么做少儿编程培训机构排名前十
  • 一个好的网站是什么样的商家联盟营销方案