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

青岛哪家做网站的公司好企业建站用什么主机

青岛哪家做网站的公司好,企业建站用什么主机,开发电商网站多少钱,在哪个网站上做苗木生意好些说明 日期:2025年5月30日 与以纯文本形式发送和接收消息的标准 HTTP 不同,HTTPS 使用SSL/TLS等协议对服务器进行身份验证、加密通信内容和检测篡改。 这样可以防止欺骗、中间人攻击和窃听等攻击。 证书很重要,如果用户主动信任了伪造证书&…

说明

日期:2025年5月30日

与以纯文本形式发送和接收消息的标准 HTTP 不同,HTTPS 使用SSL/TLS等协议对服务器进行身份验证、加密通信内容和检测篡改。 这样可以防止欺骗、中间人攻击和窃听等攻击。

证书很重要,如果用户主动信任了伪造证书,那https的优势就荡然无存了,所以不要自己添加证书。

示例

日期:2025年5月30日。
操作系统:Alibaba Cloud Linux 3.2104 LTS 64位。
应用:

  • node.js v22.15.1
  • npm 11.4.1
  • Certbot

安装SSL证书

公开的SSL证书必须使用固定域名或固定公网ip。
示例中使用域名fxxkrock.top

修改时区,有的linux失去不是中国,SSL证书含有证书起止时间,所以申请SLL证书后修改时间可能导致证书失效。

sudo timedatectl set-timezone Asia/Shanghai

添加 EPEL 仓库(Certbot 依赖)

sudo yum install -y epel-release

报错

[ecs-user@iZbp18zmckjuyndr4e25koZ server_crystalsearch]$ sudo yum install -y epel-release
Last metadata expiration check: 15:18:43 ago on Thu 29 May 2025 08:17:50 PM CST.
Error:Problem: problem with installed package epel-aliyuncs-release-8-15.1.al8.noarch- package epel-aliyuncs-release-8-15.1.al8.noarch from @System conflicts with epel-release provided by epel-release-8-22.el8.noarch from epel- package epel-aliyuncs-release-8-15.1.al8.noarch from alinux3-updates conflicts with epel-release provided by epel-release-8-22.el8.noarch from epel- conflicting requests
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

这个错误是因为系统中已经存在名为 epel-aliyuncs-release 的包,与标准的 epel-release 包冲突。

从包的名称来看,是阿里云自己兼容的epel,所以直接进行下一步。

安装certbot。

[ecs-user@iZbp18zmckjuyndr4e25koZ server_crystalsearch]$ sudo yum install -y certbot

使用 Standalone 模式(需临时停止占用 80/443 端口的服务),获取SSL证书。

[ecs-user@iZbp18zmckjuyndr4e25koZ ~]$ sudo certbot certonly --standalone -d fxxkrock.top
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)(Enter 'c' to cancel): 18015262576@189.cn- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.5-February-24-2025.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: n
Account registered.
Requesting a certificate for fxxkrock.topCertbot failed to authenticate some domains (authenticator: standalone). The Certificate Authority reported these problems:Domain: fxxkrock.topType:   connectionDetail: 47.97.27.78: Fetching http://fxxkrock.top/.well-known/acme-challenge/DqitmUHBr-4eEkBcNWoEZWzAf10C8Gwpm5ipvFxoY1U: Timeout during connect (likely firewall problem)Hint: The Certificate Authority failed to download the challenge files from the temporary standalone webserver started by Certbot on port 80. Ensure that the listed domains point to this machine and that it can accept inbound connections from the internet.Some challenges have failed.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.

报错了。从提示看,也就是网不通,要从80端口访问。

Certbot 的 Webroot 模式 和 Standalone 模式的区别

Webroot 模式
  1. 工作原理

    • 在您的网站根目录创建临时验证文件(/.well-known/acme-challenge/
    • Let’s Encrypt 服务器通过 HTTP 访问这些文件验证域名所有权
    • 需要指定网站根目录路径(如 -w /var/www/your-site
  2. 为什么需要路径

    • Certbot 需要将验证文件写入指定目录
    • Web 服务器(Nginx/Apache/Node.js)必须能通过 HTTP 80 端口访问这些文件
    • 例如:http://your-domain.com/.well-known/acme-challenge/xxxxx
  3. 优势

    • 无需停止正在运行的 Web 服务
    • 适合生产环境(服务持续可用)
    • 可与现有 Web 服务器配合使用
  4. 适用场景

    • 已有 Web 服务器运行中
    • 无法临时停止服务
    • 可访问网站根目录
Standalone 模式
  1. 工作原理

    • Certbot 自己启动临时 Web 服务器(监听 80/443 端口)
    • 直接响应 Let’s Encrypt 的验证请求
    • 无需指定路径
  2. 为什么不需要路径

    • Certbot 完全自己处理验证请求
    • 不依赖现有 Web 服务器或文件系统
    • 验证过程在内存中完成,不写入文件
  3. 优势

    • 简单快速,无需配置 Web 服务器
    • 不依赖现有网站目录结构
    • 适合无 Web 服务器的环境
  4. 代价

    • 临时停止占用 80/443 端口的服务
    • 获取证书期间服务短暂中断
    • 不适合 7x24 小时运行的关键服务

技术对比表

特性Webroot 模式Standalone 模式
需要路径✓ (必须指定网站根目录)✗ (完全自包含)
需停止服务✓ (释放80/443端口)
验证方式通过现有Web服务器访问文件自建临时Web服务器响应请求
适合场景生产环境/服务不可中断测试环境/简单快速获取证书
依赖Web服务器✓ (需配置访问.well-known目录)
证书续期影响零中断短暂中断(约10-30秒)

Node.js 场景下的最佳实践

推荐方案:Webroot 模式
# 1. 创建验证目录
sudo mkdir -p /var/www/ssl_validation/.well-known/acme-challenge# 2. 在Node.js中添加路由处理验证
const app = express();
app.get('/.well-known/acme-challenge/:token', (req, res) => {res.sendFile(`/var/www/ssl_validation/.well-known/acme-challenge/${req.params.token}`);
});# 3. 获取证书
sudo certbot certonly --webroot -w /var/www/ssl_validation -d your-domain.com
Standalone 模式应急使用:
# 1. 停止Node.js服务
sudo systemctl stop node-app# 2. 获取证书(Standalone模式)
sudo certbot certonly --standalone -d your-domain.com --preferred-challenges http# 3. 重启服务
sudo systemctl start node-app

为什么 Standalone 不需要路径?深层解释

Standalone 模式的工作流程:

  1. Certbot 启动内置的微型 HTTP 服务器(Python实现)

  2. 监听 80 端口(HTTP验证)或 443 端口(TLS-ALPN验证)

  3. 当 Let’s Encrypt 发送验证请求时:

    LE Server Certbot 请求 http://domain.com/.well-known/acme-challenge/token123 即时生成并返回验证内容 LE Server Certbot
  4. 验证通过后立即销毁临时服务器

  5. 全程不涉及文件系统操作,所有验证内容在内存中动态生成

这种设计使得 Standalone 模式:

  • 完全独立于现有 Web 基础设施
  • 不需要配置任何文件路径
  • 但要求独占端口(需临时停止其他服务)

实际应用建议

对于 Node.js 项目,推荐组合方案:

  1. 首次获取证书:使用 Standalone 模式(简单快速)

    sudo systemctl stop node-app
    sudo certbot certonly --standalone -d your-domain.com
    sudo systemctl start node-app
    
  2. 证书续期:改用 Webroot 模式(无中断)

    // 在Express中添加验证路由
    app.use('/.well-known/acme-challenge', express.static('/etc/letsencrypt/webrootauth'));
    
    # 续期配置
    sudo certbot renew --webroot -w /etc/letsencrypt/webrootauth
    
  3. 终极方案:用 Nginx 处理验证(最佳实践)

    server {listen 80;server_name your-domain.com;location /.well-known/acme-challenge {root /var/www/certbot;}location / {return 301 https://$host$request_uri;}
    }
    

    这样 Node.js 只需专注 443 端口 HTTPS 服务,完全解耦证书管理。

从资料看,在过程中,80/443 端口都要使用。

安全设备进出都开启80/443。

[ecs-user@iZbp18zmckjuyndr4e25koZ ~]$ sudo certbot certonly --standalone -d fxxkrock.top
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for fxxkrock.topSuccessfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/fxxkrock.top/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/fxxkrock.top/privkey.pem
This certificate expires on 2025-08-28.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:* Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate* Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

需要记录其中 Certificate 和 Key 的保存位置,web应用需要加载这两个文件。

修改web应用的代码

// 添加https模块
const https = require('https');// 读取SSL证书文件
const credentials = {key: fs.readFileSync('/etc/letsencrypt/live/fxxkrock.top/privkey.pem'),cert: fs.readFileSync('/etc/letsencrypt/live/fxxkrock.top/fullchain.pem')
};
// 设置端口号
const port = 3080;// 创建HTTPS服务器
const server = https.createServer(credentials, app).listen(port, () => {console.log(`HTTPS server successfully launched: https://localhost:${port}`);
});

启动web应用

权限不够,无法读取SSL证书

[ecs-user@iZbp18zmckjuyndr4e25koZ server_crystalsearch]$ node server.js
node:fs:562return binding.open(^Error: EACCES: permission denied, open '/etc/letsencrypt/live/fxxkrock.top/privkey.pem'at Object.openSync (node:fs:562:18)at Object.readFileSync (node:fs:446:35)at Object.<anonymous> (/home/ecs-user/server_crystalsearch/server.js:103:13)at Module._compile (node:internal/modules/cjs/loader:1730:14)at Object..js (node:internal/modules/cjs/loader:1895:10)at Module.load (node:internal/modules/cjs/loader:1465:32)at Function._load (node:internal/modules/cjs/loader:1282:12)at TracingChannel.traceSync (node:diagnostics_channel:322:14)at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5) {errno: -13,code: 'EACCES',syscall: 'open',path: '/etc/letsencrypt/live/fxxkrock.top/privkey.pem'
}Node.js v22.15.1

复制这两证书到网站目录,并修改js代码,把文件路径改为新路径。

[ecs-user@iZbp18zmckjuyndr4e25koZ server_crystalsearch]$ sudo cp /etc/letsencrypt/live/fxxkrock.top/privkey.pem /home/ec
s-user/server_crystalsearch/privkey.pem
[ecs-user@iZbp18zmckjuyndr4e25koZ server_crystalsearch]$ sudo cp /etc/letsencrypt/live/fxxkrock.top/fullchain.pem /home/
ecs-user/server_crystalsearch/fullchain.pem

启动过程无报错

[ecs-user@iZbp18zmckjuyndr4e25koZ server_crystalsearch]$ node server.js
Web folder:  /home/ecs-user/server_crystalsearch/crystalsearch
HTTPS server successfully launched: https://localhost:3060

浏览器访问http://fxxkrock.top:3060/,浏览器显示“响应时间过长”。

访问https://fxxkrock.top:3060/,浏览器显示“响应时间过长”。

忘记在安全设备打开3060端口了。

打开后,https正常,控制台无报错。

访问http会自动跳转到https。


文章转载自:

http://dJ1w4U1O.Lzqxb.cn
http://PMTQecds.Lzqxb.cn
http://LK5njHc5.Lzqxb.cn
http://ss0ox8zB.Lzqxb.cn
http://bekSSNyI.Lzqxb.cn
http://nOb02IaM.Lzqxb.cn
http://aAxIwYWe.Lzqxb.cn
http://Cm6LPz4T.Lzqxb.cn
http://2L7nb7HO.Lzqxb.cn
http://feY96Tbk.Lzqxb.cn
http://KEh4euBF.Lzqxb.cn
http://RF3v9i4i.Lzqxb.cn
http://sa9JcLYv.Lzqxb.cn
http://YAGUEcgm.Lzqxb.cn
http://3Zjdt6lF.Lzqxb.cn
http://pLi3ldzQ.Lzqxb.cn
http://HsVkiNmc.Lzqxb.cn
http://bhbBgSKZ.Lzqxb.cn
http://j4jVU7Dc.Lzqxb.cn
http://xeBd0h2y.Lzqxb.cn
http://7OXOQNJe.Lzqxb.cn
http://MficFkjC.Lzqxb.cn
http://lMnlf2xk.Lzqxb.cn
http://WUCHqCLX.Lzqxb.cn
http://KJym67KU.Lzqxb.cn
http://vzCmuqmi.Lzqxb.cn
http://9Rr4nXCY.Lzqxb.cn
http://Wlukt56d.Lzqxb.cn
http://whiT9D7X.Lzqxb.cn
http://e8yEhl0D.Lzqxb.cn
http://www.dtcms.com/wzjs/620336.html

相关文章:

  • 扬州市邗江区城乡建设局网站电商网站的建设案例
  • 平面设计网站模板vi设计方案模板
  • 绵阳市建设工程质量监督站网站昆明网站建设
  • 广州网站优化排名推广vr全景网站开发
  • 公司如何登录网站做就业登记软件商店哪个好
  • 做排名出租网站一加手机官网网站
  • 中国建设工程招标官方网站企业网站建设中企动力
  • 做网站美工未来规划太原百度快速排名提升
  • 怎样用ps做网站首页图片网页的六个基本元素
  • 高端制作网站技术wordpress的统计代码
  • 网站推广的常用方法有哪些?wordpress git wiki
  • 公司外包做网站赚钱吗吉林关键词优化的方法
  • 有哪些做红色旅游景点的网站简约大方网站
  • 简单的房源展示网站开发百度搜索名字排名优化
  • 如何给公司做网站网站引导页flash
  • 网站开发工程师特点屋领网站固链
  • 淘宝可以到哪些网站做推广重庆网站建设最大
  • 有哪些ui的设计网站竞价排名适合百度吗
  • 做电子相册的大网站搜索引擎排名国内
  • 网站如何提高流量做网站如何月入10万
  • 空间购买网站邯郸企业建网站
  • 怎么做属于自己的免费网站wordpress主题首页修改
  • 一个人可以建设网站吗哈尔滨网页制作费用
  • 凡科建站怎么删除网站建设wordpress文章页打赏
  • 临沂恒商做网站自己做海报的网站
  • 建设银行个人网站登陆汽车信息网站设计论文
  • 注重网站开发设计与建设网站设计的流程是怎样的
  • whois查询 站长工具建立簇状柱形图怎么设置
  • 石家庄市桥西区建设局网站北京网站建设58
  • 杭州高端网站建设公司360搜索引擎优化