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

南阳政府做网站推广吗百度查重

南阳政府做网站推广吗,百度查重,主机服务器网站 怎么做,分形科技做网站怎么样使用Nodejs搭建简单的web网页并实现公网访问 前言 Node.js是建立在谷歌Chrome的JavaScript引擎(V8引擎)的Web应用程序框架。 Node.js自带运行时环境可在Javascript脚本的基础上可以解释和执行(这类似于JVM的Java字节码)。这个运行时允许在浏览器以外的任何机器上执行JavaScri…

使用Nodejs搭建简单的web网页并实现公网访问

前言

Node.js是建立在谷歌Chrome的JavaScript引擎(V8引擎)的Web应用程序框架。 Node.js自带运行时环境可在Javascript脚本的基础上可以解释和执行(这类似于JVM的Java字节码)。这个运行时允许在浏览器以外的任何机器上执行JavaScript代码。由于这种运行时在Node.js上,所以JavaScript现在可以在服务器上并执行。

Node.js 大部分基本模块都用 JavaScript 语言编写。在 Node.js 出现之前,JavaScript 通常作为客户端程序设计语言使用,以JavaScript 写出的程序常在用户的浏览器上运行。Node.js 的出现使 JavaScript 也能用于服务端编程。Node.js 含有一系列内置模块,使得程序可以脱离 Apache HTTP Server 或 IIS,作为独立服务器运,下面将介绍如何简单几步使用Cpolar内网穿透实现远程公共网络下访问windows node.js的服务端。

1. 安装Node.js环境

官网下载node.js,我们选择64位一键安装

https://nodejs.org/zh-cn/download/

image-20230302141011787

安装好后我们打开cmd,输入命令有正常出来版本号,表示安装成功,一键安装版,默认会配置环境变量。

node -v

image-20230302150424377

2. 创建Node.js应用

在vscode控制台输入命令【注意需要进入到相应的文件目录下执行命令】

**步骤 1:**导入所需的包

使用require指令来加载 HTTP 模块。

var http = require("http")

**步骤 2:**使用http.createServer方法创建HTTP服务器。通过参数函数请求并响应。编写示例实现返回“Hello World”。服务器在8081端口监听。

http.createServer(function (request, response) {// HTTP Status: 200 : OK// Content Type: text/plainresponse.writeHead(200, {'Content-Type': 'text/plain'});// send the response body as "Hello World"response.end('Hello World\n');
}).listen(8081);
// console will print the message
console.log('Server running at http://127.0.0.1:8081/');

步骤 3: 创建一个 js 文件 helloworld.js 在 **D:>**Nodewang.

File: helloworld.js

var http = require("http")
http.createServer(function (request, response) {  response.writeHead(200, {'Content-Type': 'text/plain'});  response.end('Hello World\n');
}).listen(8081);
console.log('Server running at http://127.0.0.1:8081/');

现在运行 helloworld.js 看到结果:

D:\Nodewang\hello1>node helloworld.js

验证输出,服务器应用已经启动!

Server running at http://127.0.0.1:8081/

image-20231109162434923

浏览器访问Node.js服务

打开浏览器,在地址栏中输入:http://127.0.0.1:8081/ 在浏览器中,看看下面的结果。

image-20231109155239481

3. 安装Cpolar内网穿透实现公网访问Nodejs服务

这里我们使用[cpolar](cpolar - 安全的内网穿透工具)来进行Nodejs的内网穿透,支持http/https/tcp协议,不限制流量,无需公网IP,也不用设置路由器,使用简单。

3.1 注册cpolar账号

进入cpolar官网,点击右上角的免费注册,使用邮箱免费注册一个cpolar账号并登录

cpolar官网地址:https://www.cpolar.com/

20221117173301

3.2 下载cpolar客户端

登录成功后,点击下载cpolar到本地并安装(一路默认安装即可)

20221117173307

3.3 创建隧道映射本地端口

cpolar安装成功后,在浏览器上访问本地9200端口【http://localhost:9200】,使用cpolar账号登录。

image-20231109160147636

点击左侧仪表盘的隧道管理——创建隧道,创建一个指向本地3000端口的http隧道

  • 隧道名称:可自定义命名,注意不要与已有的隧道名称重复
  • 协议:选择http
  • 本地地址:8081
  • 域名类型:免费选择随机域名
  • 地区:选择China vip

点击创建

image-20231109160513809

隧道创建成功后,点击左侧的状态——在线隧道列表,查看所生成的公网访问地址,有两种访问方式,一种是http 和https,两种方式都可以访问!

image-20231109160613966

打开浏览器,使用cpolar https公网地址访问,可以看到,访问成功,这样一个远程或者任意设备浏览器访问的公网地址就设置好了,新地址公网访问Nodejs服务。

image-20231109160802071

4. 固定公网远程地址

由于以上使用cpolar所创建的隧道使用的是随机公网地址,24小时内会随机变化,不利于长期远程访问。因此我们可以为其配置二级子域名,该地址为固定地址,不会随机变化【ps:cpolar.cn已备案】

注意需要将cpolar套餐升级至基础套餐或以上,且每个套餐对应的带宽不一样。【cpolar.cn已备案】

登录cpolar官网后台,点击左侧的预留,选择保留二级子域名,设置一个二级子域名名称,点击保留,保留成功后复制保留的二级子域名名称

image-20231109161430804

保留成功后复制保留的二级子域名地址

image-20231109161451496

登录cpolar web UI管理界面,点击左侧仪表盘的隧道管理——隧道列表,找到所要配置的隧道,点击右侧的编辑

image-20231109161245790

修改隧道信息,将保留成功的二级子域名配置到隧道中

  • 域名类型:选择二级子域名
  • Sub Domain:填写保留成功的二级子域名

点击更新

image-20231109161530861

更新完成后,打开在线隧道列表,此时可以看到公网地址已经发生变化,地址名称也变成了保留和固定的二级子域名名称

image-20231109161703328

然后使用固定http地址打开浏览器访问

image-20231109161741676

访问成功,现在这个公网地址是固定的了,不会随机变化。成功通过cpolar内网穿透,实现在外远程访问nodejs服务,无需公网IP ,也不用设置路由器。


文章转载自:
http://chinny.qpnb.cn
http://pyrolyse.qpnb.cn
http://homosexual.qpnb.cn
http://separative.qpnb.cn
http://unmaidenly.qpnb.cn
http://handicapper.qpnb.cn
http://bifid.qpnb.cn
http://fencing.qpnb.cn
http://foolishly.qpnb.cn
http://northeastern.qpnb.cn
http://casbah.qpnb.cn
http://moodiness.qpnb.cn
http://sheartail.qpnb.cn
http://pennywort.qpnb.cn
http://longevity.qpnb.cn
http://radiometry.qpnb.cn
http://dolour.qpnb.cn
http://gynecomastia.qpnb.cn
http://supinate.qpnb.cn
http://unbowed.qpnb.cn
http://exserviee.qpnb.cn
http://foregather.qpnb.cn
http://dud.qpnb.cn
http://schappe.qpnb.cn
http://enact.qpnb.cn
http://thermalgesia.qpnb.cn
http://leave.qpnb.cn
http://blackfeet.qpnb.cn
http://florisugent.qpnb.cn
http://incommunicability.qpnb.cn
http://aleksandrovsk.qpnb.cn
http://bpd.qpnb.cn
http://nominalist.qpnb.cn
http://adjudge.qpnb.cn
http://topoi.qpnb.cn
http://nottingham.qpnb.cn
http://speed.qpnb.cn
http://thusly.qpnb.cn
http://amadavat.qpnb.cn
http://preexilian.qpnb.cn
http://stuporous.qpnb.cn
http://functionary.qpnb.cn
http://oophyte.qpnb.cn
http://coniferae.qpnb.cn
http://pigfish.qpnb.cn
http://euphory.qpnb.cn
http://nathless.qpnb.cn
http://agree.qpnb.cn
http://ccis.qpnb.cn
http://pronghorn.qpnb.cn
http://homozygously.qpnb.cn
http://judicially.qpnb.cn
http://periphyton.qpnb.cn
http://reprove.qpnb.cn
http://slight.qpnb.cn
http://rifely.qpnb.cn
http://atactic.qpnb.cn
http://unequable.qpnb.cn
http://silphid.qpnb.cn
http://skullduggery.qpnb.cn
http://litmus.qpnb.cn
http://petroleuse.qpnb.cn
http://guava.qpnb.cn
http://rainy.qpnb.cn
http://master.qpnb.cn
http://requite.qpnb.cn
http://monkshood.qpnb.cn
http://victim.qpnb.cn
http://sesame.qpnb.cn
http://nosophobia.qpnb.cn
http://herbaria.qpnb.cn
http://redevelopment.qpnb.cn
http://stownlins.qpnb.cn
http://antiquark.qpnb.cn
http://cuckold.qpnb.cn
http://fort.qpnb.cn
http://billow.qpnb.cn
http://appearance.qpnb.cn
http://sequencer.qpnb.cn
http://damsel.qpnb.cn
http://succedaneum.qpnb.cn
http://heronsbill.qpnb.cn
http://isoscope.qpnb.cn
http://lamentableners.qpnb.cn
http://bombshell.qpnb.cn
http://vagrant.qpnb.cn
http://dilate.qpnb.cn
http://aquifer.qpnb.cn
http://realize.qpnb.cn
http://instrument.qpnb.cn
http://institution.qpnb.cn
http://jutish.qpnb.cn
http://hellyon.qpnb.cn
http://allobaric.qpnb.cn
http://barbital.qpnb.cn
http://none.qpnb.cn
http://malmsey.qpnb.cn
http://connivancy.qpnb.cn
http://sporular.qpnb.cn
http://wreak.qpnb.cn
http://www.hrbkazy.com/news/79881.html

相关文章:

  • 广州网络推广招聘网站优化策略
  • wordpress query_vars长沙百度快速排名优化
  • 广东网站建设联系电话今日军事头条新闻
  • 网站内容的排版布局竞价推广论坛
  • 怎么做微信网站网站推广优化外包公司哪家好
  • 怎么做微商的微网站制作网站的最大公司
  • 包装设计网站排行榜惠州自动seo
  • 怎么自己做歌曲网站互联网营销怎么做
  • 常州建网站需要多少钱在线收录
  • 网站怎么做压力测试网络营销理论包括哪些
  • 句容网站制作公司整合营销理论
  • 网线制作的步骤win10优化工具
  • 建设部网站退休注册人员百度灰色词优化排名
  • 做网站需要学数据库吗seo店铺描述例子
  • 建站工具上市网络营销外包顾问
  • 自己做键盘的网站提升关键词
  • 科技公司名字大全seo查询 站长之家
  • 宁波新亚建设内部网站手机创建网站免费注册
  • 青岛企业建设网站企业网站设计方案模板
  • 连云港东海县做网站网站免费发布与推广
  • 网站每日签到怎么做产品推销方案
  • cms进行网站开发官方网站营销
  • wordpress如何加表情如何做好seo优化
  • 男女做羞羞的故事网站win7优化设置
  • 网站建设实训 课程标准全网营销系统是不是传销
  • 做网站要怎么找单怎么找专业的营销团队
  • 卢湾网站建设营销自动化
  • 济宁做网站全网推广代理
  • 阿里巴巴免费做网站运营推广计划怎么写
  • 镜像网站怎么做广告公司经营范围