分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

nginx配置https

发布时间:2023-09-06 01:52责任编辑:白小东关键词:配置nginxhttp

HTTPS配置场景

秘钥生成操作步骤

1.生成key密钥
2.生成证书签名请求文件(csr文件)
3.生成证书签名文件(CA文件)

 1.检查当前环境

//openssl必须是1.0.2[root@Nginx ~]# openssl versionOpenSSL 1.0.2k-fips ?26 Jan 2017//nginx必须有ssl模块[root@Nginx ~]# nginx -V --with-http_ssl_module [root@Nginx ~]# mkdir /usr/local/nginx/conf/ssl -p[root@Nginx ~]# cd //usr/local/nginx/conf/ssl 

2.创建私钥

[root@Nginx ssl]# openssl genrsa -idea -out server.key 2048Generating RSA private key, 2048 bit long modulus.....+++//记住配置密码, 我这里是1234Enter pass phrase for server.key:Verifying - Enter pass phrase for server.key:

3.生成使用签名请求证书和私钥生成自签证书

[root@Nginx ssl]# openssl req -days 36500 -x509 -sha256 -nodes -newkey rsa:2048 -keyout server.key -out server.crtCountry Name (2 letter code) [XX]:CNState or Province Name (full name) []:SZLocality Name (eg, city) [Default City]:SZOrganization Name (eg, company) [Default Company Ltd]:edu ???Organizational Unit Name (eg, section) []:SACommon Name (eg, your name or your server‘s hostname) []:xuli  Email Address []:xuli@foxmail.com

4.配置nginx访问的配置文件

server { ???listen 443; ???server_name localhost; ???ssl on; ???index index.html index.htm index.php; ???#ssl_session_cache share:SSL:10m; ???ssl_session_timeout 10m; ???ssl_certificate ??/usr/local/nginx/conf/ssl/server.crt; ???ssl_certificate_key ?/usr/local/nginx/conf/ssl/server.key; ???ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ???ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ???ssl_prefer_server_ciphers on; ???????location / { ?access_log /data/wwwlogs/www.ikmak.com_nginx.log combined; ?index index.html index.htm index.php; ?root /data/wwwroot/default; ???????} ???????location ~ [^/]\.php(/|$) { ???#fastcgi_pass remote_php_ip:9000; ???fastcgi_pass unix:/dev/shm/php-cgi.sock; ???fastcgi_index index.php; ???include fastcgi.conf; ???fastcgi_split_path_info ^(.+\.php)(/.+)$; ???fastcgi_param ??PATH_INFO ??$fastcgi_path_info; ???fastcgi_param ??SCRIPT_FILENAME $document_root$fastcgi_script_name; ?}}server { ???????listen 80; ???????server_name localhost; ???????rewrite ^(.*) https://$server_name$1 redirect;}

  

nginx配置https

原文地址:https://www.cnblogs.com/jimmy-xuli/p/8990069.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved