nginx 1.18配置ssl问题

简介: nginx1.18配置ssl问题

把一个NETCORE网站部署到NGINX上,按微软官方文档弄好了 https://docs.microsoft.com/zh-cn/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-3.1

想配置SSL的HTTPS证书,腾讯云上申请了免费的,之前在WIN+IIS 配置是成功的,按网上的弄好了,我的用的是宝塔的NGINX,可以在网页上建立网站了改NGINX配置文件就行了,

配置好后重启NGINX了,结果不行的,搜索一翻,原来是centos服务器自带的firewall防火墙的问题,https://www.jianshu.com/p/17b73ad6a4b8, xshel上运行以下命令就行了

firewall-cmd --zone=public --add-port=443/tcp --permanent 增加443端口

firewall-cmd --reload 重启防火墙

或者直接就把防火墙停掉

systemctl stop firewalld

其他备注:

在xshell 里登录LINUX服务器后,输入BT命令,可以查看宝塔默认的安装信息

1.png
2.png

以下是我的nginx配置文件:

server {
listen 80;
server_name tudi.niunan.net;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {

 #SSL 访问端口号为 443
 listen 443 ssl; 
 #填写绑定证书的域名
 server_name tudi.niunan.net;
 #证书文件名称
 ssl_certificate /www/server/nginx/conf/1_tudi.niunan.net_bundle.crt; 
 #私钥文件名称
 ssl_certificate_key /www/server/nginx/conf/2_tudi.niunan.net.key; 
 ssl_session_timeout 5m;
 #请按照以下协议配置
 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
 #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; 
 ssl_prefer_server_ciphers on;
 location / {

proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;

 }

}

目录
相关文章
|
5天前
|
JavaScript 应用服务中间件 nginx
【项目部署系列教程】5. nginx配置反向代理,解决跨域接口的访问
【项目部署系列教程】5. nginx配置反向代理,解决跨域接口的访问
24 10
|
1天前
|
应用服务中间件 nginx
Nginx命令配置到系统环境变量
Nginx命令配置到系统环境变量
|
1天前
|
应用服务中间件 开发工具 nginx
Nginx基础配置实例需求分析
Nginx基础配置实例需求分析
|
4天前
|
负载均衡 JavaScript 应用服务中间件
手把手教你玩转 Nginx 配置
作为静态服务器、反代和负载均衡器,Nginx 因高性能和灵活性广泛使用。
39 5
|
1天前
|
应用服务中间件 Linux nginx
CentOS 7 上配置 Nginx 作为反向代理
在CentOS 7上设置Nginx反向代理的步骤:安装Nginx;启动Nginx服务编辑`/etc/nginx/nginx.conf`;添加`proxy_pass http://app_server_address;将请求转发至应用服务器;重启Nginx`sudo systemctl restart nginx`;验证配置是否成功
|
1天前
|
网络协议 应用服务中间件 nginx
Nginx的http块sendfile,keepalive_timeout的配置指令说明
Nginx的http块sendfile,keepalive_timeout的配置指令说明
|
4天前
|
应用服务中间件 网络安全 nginx
|
6天前
|
网络协议 应用服务中间件 网络安全
如何排查Nginx配置问题导致的域名访问错误
如何排查Nginx配置问题导致的域名访问错误
21 2
|
6天前
|
应用服务中间件 nginx
如何通过Nginx配置将请求转发到conf.d目录下的各个配置文件
如何通过Nginx配置将请求转发到conf.d目录下的各个配置文件
21 2
|
10天前
|
网络安全
宝塔配置ssl证书没有生效
宝塔配置ssl证书没有生效
21 4