腾讯云 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访问你的域名。当然还要记得域名要备案,否则访问还是不通的,或者通了几天就被封了。

相关推荐
七夜zippoe6 小时前
CANN Runtime任务描述序列化与持久化源码深度解码
大数据·运维·服务器·cann
盟接之桥7 小时前
盟接之桥说制造:引流品 × 利润品,全球电商平台高效产品组合策略(供讨论)
大数据·linux·服务器·网络·人工智能·制造
Fcy6488 小时前
Linux下 进程(一)(冯诺依曼体系、操作系统、进程基本概念与基本操作)
linux·运维·服务器·进程
袁袁袁袁满8 小时前
Linux怎么查看最新下载的文件
linux·运维·服务器
主机哥哥8 小时前
阿里云OpenClaw部署全攻略,五种方案助你快速部署!
服务器·阿里云·负载均衡
Harvey9038 小时前
通过 Helm 部署 Nginx 应用的完整标准化步骤
linux·运维·nginx·k8s
珠海西格电力科技10 小时前
微电网能量平衡理论的实现条件在不同场景下有哪些差异?
运维·服务器·网络·人工智能·云计算·智慧城市
释怀不想释怀10 小时前
Linux环境变量
linux·运维·服务器
zzzsde10 小时前
【Linux】进程(4):进程优先级&&调度队列
linux·运维·服务器
qq_2975746711 小时前
Linux 服务器 Java 开发环境搭建保姆级教程
java·linux·服务器