网站首页 > 技术教程 正文
配置文件:/etc/nginx/nginx.conf
html文件:/usr/share/nginx/html
配置文件中配置TLS
- 取消“Setting for a TLS enabled server.”部分的注释
- 申请SSL证书,和域名相关,在域名服务商处申请
- 上传证书到服务器
- 修改文中引用加粗部分(abc.xyz是你的真实域名)
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name abc.xyz;
root /usr/share/nginx/html;
# 为了能够将http请求重定向到https
rewrite ^(.*)$ https://$server_name$1 permanent;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name abc.xyz;
root /usr/share/nginx/html;
ssl on;
ssl_certificate "/etc/pki/nginx/Nginx/1_abc.xyz_bundle.crt";
ssl_certificate_key "/etc/pki/nginx/Nginx/2_abc.xyz.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
猜你喜欢
- 2024-10-11 部署支持 https 的 Nginx 服务(nginx配置https证书)
- 2024-10-11 nginx优化https(ocsp)(nginx配置生成https)
- 2024-10-11 Nginx配置HTTPS(nginx配置带重定向的反向代理)
- 2024-10-11 Linux下配置Nginx并使用https协议
- 2024-10-11 超详解:HTTPS及配置Django+HTTPS开发环境
- 2024-10-11 如何使网站支持https访问?nginx配置https证书
- 2024-09-21 搭建Nginx(Https)+Tomcat实现负载均衡且Https自发证书配置
- 2024-09-21 「python」「nginx」「https」 Nginx 服务器 SSL 证书安装部署
- 2024-09-21 Nginx配置https实现加密认证(https加密证书)
- 2024-09-21 Nginx HTTPS的正反向代理测试(没有为http或https指定代理服务器)
你 发表评论:
欢迎- 最近发表
-
- Linux新手必看:几种方法帮你查看CPU核心数量
- linux基础命令之lscpu命令(linux中ls命令的用法)
- Linux lscpu 命令使用详解(linux常用ls命令)
- 如何查询 Linux 中 CPU 的数量?这几个命令要知道!
- 在linux上怎么查看cpu信息(linux如何查看cpu信息)
- 查看 CPU 的命令和磁盘 IO 的命令
- 如何在CentOS7上改变网卡名(centos怎么改网卡名字)
- 网工必备Linux网络管理命令(网工必备linux网络管理命令是什么)
- Linux 网络命令知多少(linux 网络 命令)
- Linux通过命令行连接wifi的方式(linux命令行连接无线网)
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)