腾讯云 Nginx 服务器 SSL 证书安装部署(Windows)

和其他服务器基本没啥差别

官方说明:

1、本文以证书名称 cloud.tencent.com 为例。

2、Nginx 版本以 nginx/1.24.0 为例。

3、当前服务器的操作系统为 Windows Server 2022,由于操作系统的版本不同,详细操作步骤略有区别。

4、安装 SSL 证书前,请您在服务器上开启 HTTPS 默认端口 443,避免证书安装后无法启用 HTTPS。

这简直是废话。

第一步。好了,先安装nginx吧。

去这里下载nginx:https://nginx.org/

如图:

最上面的一般书最新版本。点开。如图:

最上面的一般是最新版本。这里因为是windows环境,这里现在后面带windows的。下载下来的是zip压缩包。解压。如图:

如图,把ssl的证书解压之后,放在nginx的目录下。需要注意的是,ssl有针对不同容器的版本,这个在证书的管理页面下载时就可以看见,我这里用nginx来发布的,所以这里就需要nginx的版本。

第二步,打开nginx的nginx.conf配置文件,先备份一个原版的,然后修改成下面的

#user nobody;

worker_processes 1;

#error_log logs/error.log;

#error_log logs/error.log notice;

#error_log logs/error.log info;

#pid logs/nginx.pid;

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

#log_format main '$remote_addr - remote_user \[time_local] "$request" '

'$status body_bytes_sent "http_referer" '

'"http_user_agent" "http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

keepalive_timeout 65;

#gzip on;

server {

listen 80;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

root html;

index index80.htm; //这个文件是我自己添加的,代替ngxin的默认页面,防止信息泄露。

}

#error_page 404 /404.html;

redirect server error pages to the static page /50x.html

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

proxy the PHP scripts to Apache listening on 127.0.0.1:80

#location ~ \.php$ {

proxy_pass http://127.0.0.1;

#}

pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#location ~ \.php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

include fastcgi_params;

#}

deny access to .htaccess files, if Apache's document root

concurs with nginx's one

#location ~ /\.ht {

deny all;

#}

}

another virtual host using mix of IP-, name-, and port-based configuration

#server {

listen 8000;

listen somename:8080;

server_name somename alias another.alias;

location / {

root html;

index index.html index.htm;

}

#}

HTTPS server

server {

#SSL 默认访问端口号为 443

listen 443 ssl;

#请填写绑定证书的域名

server_name xxxxx.online;

#请填写证书文件的相对路径或绝对路径

ssl_certificate xxxxx.online_bundle.crt;

#请填写私钥文件的相对路径或绝对路径

ssl_certificate_key xxxxx.online.key;

ssl_session_timeout 5m;

#请按照以下协议配置

ssl_protocols TLSv1.2 TLSv1.3;

#请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。

ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;

ssl_prefer_server_ciphers on;

#location / {

#网站主页路径。此路径仅供参考,具体请您按照实际目录操作。

#例如,您的网站主页在 Nginx 服务器的 /etc/www 目录下,则请修改 root 后面的 html 为 /etc/www。

root html;

index index80.htm;

#}

location /api/{

proxy_set_header Host $http_host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header REMOTE-HOST $remote_addr;

add_header 'Access-Control-Allow-Credentials' 'true';

add_header 'Access-Control-Allow-Origin' '*';

add_header 'Access-Control-Allow-Methods' 'GET,POST,PATCH,OPTIONS';

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://localhost:15666/; //这个是本地应用http正常发布的地址。记得在防火墙里面需要把相应的端口、80端口、443端口全部开放。否则nginx代理转跳的时候跳不过去。

}

}

}

第三步,启动nginx。这样就好了。试试外面用https访问你的域名。当然还要记得域名要备案,否则访问还是不通的,或者通了几天就被封了。

相关推荐
落笔画忧愁e34 分钟前
FastGPT快速将消息发送至飞书
服务器·数据库·飞书
小冷爱学习!41 分钟前
华为动态路由-OSPF-完全末梢区域
服务器·网络·华为
落幕2 小时前
C语言-进程
linux·运维·服务器
xmweisi5 小时前
【华为】报文统计的技术NetStream
运维·服务器·网络·华为认证
DC_BLOG5 小时前
Linux-GlusterFS进阶分布式卷
linux·运维·服务器·分布式
yourkin6666 小时前
TCP...
服务器·网络·tcp/ip
cookies_s_s6 小时前
Linux--进程(进程虚拟地址空间、页表、进程控制、实现简易shell)
linux·运维·服务器·数据结构·c++·算法·哈希算法
诶尔法Alpha7 小时前
Linux上使用dify构建RAG
linux·运维·服务器
熬夜苦读学习8 小时前
Linux文件系统
linux·运维·服务器·开发语言·后端
荔枝荷包蛋6668 小时前
【网络】高级IO——Reactor版TCP服务器
运维·服务器