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

相关推荐
哇哈哈&2 小时前
gcc9.2的离线安装,支持gcc++19及以上版本
linux·运维·服务器
一条咸鱼¥¥¥3 小时前
【运维经验】使用QQ邮箱SMTP服务器设置ssms计划任务完成时邮件发送
运维·服务器·经验分享·sql·sqlserver
菜鸟plus+3 小时前
N+1查询
java·服务器·数据库
Caster_Z5 小时前
WinServer安装VM虚拟机运行Linux-(失败,云服务器不支持虚拟化)
linux·运维·服务器
中屹指纹浏览器6 小时前
指纹浏览器抗检测进阶:绕过深度风控的技术实践
服务器·网络·经验分享·笔记·媒体
model20056 小时前
Alibaba linux 3安装LAMP(5)
linux·运维·服务器
Macbethad9 小时前
工业触摸屏技术指南:选型、难点与实战解决方案
服务器·前端·数据库
王 富贵9 小时前
【Linux】防火墙常用命令(iptables/firewalld/ufw)
linux·运维·服务器
写代码的【黑咖啡】10 小时前
Linux系统简介及常用命令分类详解
linux·运维·服务器
lang2015092810 小时前
Sentinel限流核心:ThrottlingController设计详解
服务器·网络·sentinel