IT常识
技术 Python PHP JavaScript IOS Android Java 数据库 资源 公众号 代码片段 github
  • IT常识
  • JavaScript

nodejs简易代理服务器

Posted 2020-09-14

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nodejs简易代理服务器相关的知识,希望对你有一定的参考价值。

直接代码:

var http = require(\'http\')
var proxy = http.createServer(function (request, response) {
  var options = {
    host: \'www.cnblogs.com\', // 这里是代理服务器       
    port: 80, // 这里是代理服务器端口
    path: request.url,
    method: request.method
  }
  var req = http.request(options, function (res) {
    res.pipe(response);
  }).end();

}).listen(3000, \'localhost\')

  

以上是关于nodejs简易代理服务器的主要内容,如果未能解决你的问题,请参考以下文章

nodejs构建多房间简易聊天室

nodeJS实现简易爬虫

express搭建简易web的服务器

NodeJs+Express+SqlServer简易后台API服务搭建

nodejs常用代码片段

使用 NodeJS 和 JSDOM/jQuery 从代码片段构建 PHP 页面

(c)2006-2024 SYSTEM All Rights Reserved IT常识