广告
返回顶部
首页 > 资讯 > 数据库 >Centos下nginx配置https证书的操作步骤
  • 200
分享到

Centos下nginx配置https证书的操作步骤

2024-04-02 19:04:59 200人浏览 安东尼
摘要

这篇文章主要讲解了“Centos下Nginx配置https证书的操作步骤”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Centos下nginx配置Https

这篇文章主要讲解了“CentosNginx配置https证书的操作步骤”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Centos下nginx配置Https证书的操作步骤”吧!

1、首先配置nginx及其他插件,这个Google下,很多配置方案。

2、配置服务器的证书。操作步骤如下:

[root@localhost ~]# cd /etc/pki/tls/certs 

[root@localhost certs]# make server.key 

umask 77 ;

/usr/bin/openssl genrsa -aes128 2048 > server.key

Generating RSA private key, 2048 bit long modulus

......................................................++++++

.............++++++

e is 61251 (0x10001)

Enter pass phrase:# set passphrase

Verifying - Enter pass phrase:# confirm

# remove passphrase from private key

[root@localhost certs]# openssl rsa -in server.key -out server.key 

Enter pass phrase for server.key:# input passphrase

writing RSA key

[root@localhost certs]#

[root@localhost certs]# make server.csr 

umask 77 ;

/usr/bin/openssl req -utf8 -new -key server.key -out server.csr

You are about to be asked to enter infORMation that will be incorporated

into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN.

There are quite a few fields but you can leave some blank

For some fields there will be a default value,

If you enter '.', the field will be left blank.

-----

Country Name (2 letter code) [XX]:CN #country

State or Province Name (full name) [e]:Beijing   #state

Locality Name (eg, city) [Default City]:Beijing  #city

Organization Name (eg, company) [Default Company Ltd]:Test   #company

Organizational Unit Name (eg, section) []:Test Haha   #department

Common Name (eg, your server's hostname) []:www.test.com   #server's FQDN

Email Address []:admin@test.com # email address

Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge passWord []:# Enter

An optional company name []:# Enter

[root@localhost certs]#

[root@localhost certs]# openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650

Signature ok

subject=/C=CN/ST=Beijing/L=Beijing/O=Test/OU=Test Haha/CN=www.test.com,/emailAddress=admin@test.com 

Getting Private key

[root@localhost certs]# chmod 400 server.*

3、配置nginx的conf文件

#server {

#       listen 80;

#       server_name happy.cc.com;

#       rewrite ^(.*)$  permanent;

#      }

server {

       listen 80;

       listen 443 ssl;

       server_name happy.cc.com;

       location / {

       root   /data/www/cloud;

       index  index.html;                                                                                                                                                                                                                   

       }

       ssl on;

       ssl_certificate /data/WEBserver/nginx/conf/server.crt;

       ssl_certificate_key /data/webserver/nginx/conf/server.key;

       ssl_session_timeout 5m;

       ssl_protocols  SSLv3 TLSv1;

       ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

       ssl_prefer_server_ciphers   on;

       #autoindex on;

       location = /favicon.ico {

       log_not_found off;

       access_log off;

       }

       location ~ .PHP$ {

       root           /data/www/cloud;

       fastcgi_pass   unix:/tmp/php-cgi.sock;

       #fastcgi_pass   127.0.0.1:9000;

       fastcgi_index  index.php;

       fastcgi_param  SCRIPT_FILENAME  /data/www/cloud$fastcgi_script_name;

       include        fastcgi_params;

       }

       location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$

       {

       expires 30d;

       }

       location ~ .*.(js|CSS)?$

       {

       expires 1h;

       }

      access_log /data/log/nginx/happy.access.log access;

      error_log /data/log/nginx/happy.error.log warn;

     }

4、打开iptables的443端口

感谢各位的阅读,以上就是“Centos下nginx配置https证书的操作步骤”的内容了,经过本文的学习后,相信大家对Centos下nginx配置https证书的操作步骤这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是编程网,小编将为大家推送更多相关知识点的文章,欢迎关注!

您可能感兴趣的文档:

--结束END--

本文标题: Centos下nginx配置https证书的操作步骤

本文链接: https://www.lsjlt.com/news/60204.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作