var http = require('http');
var https = require('https');
var httpPort = 3345;
var server = http.createServer(function(req, res){
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('hello world!');
}).listen(httpPort);
var https = require('https');
var fs = require('fs');
var httpsPort = 3346;
var options = {
key: fs.readFileSync('./cakey.pem'),
cert: fs.readFileSync('./cacert.pem')
};
var sserver = https.createServer(options, function(req, res){
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('secured hello world');
}).listen(httpsPort);
var net = require('net');
var http = require('http');
var https = require('https');
var fs = require('fs');
var httpPort = 3345;
var httpsPort = 3346;
var server = http.createServer(function(req, res){
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('hello world!');
}).listen(httpPort);
var options = {
key: fs.readFileSync('./cakey.pem'),
cert: fs.readFileSync('./cacert.pem')
};
var sserver = https.createServer(options, function(req, res){
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('secured hello world');
}).listen(httpsPort);
net.createServer(function(socket){
socket.once('data', function(buf){
console.log(buf[0]);
// https数据流的第一位是十六进制“16”,转换成十进制就是22
var address = buf[0] === 22 ? httpsPort : httpPort;
//创建一个指向https或http服务器的链接
var proxy = net.createConnection(address, function() {
proxy.write(buf);
//反向代理的过程,tcp接受的数据交给代理链接,代理链接服务器端返回数据交由socket返回给客户端
socket.pipe(proxy).pipe(socket);
});
proxy.on('error', function(err) {
console.log(err);
});
});
socket.on('error', function(err) {
console.log(err);
});
}).listen(3344);
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有