191145692 发表于 2018-11-16 07:50:29

nginx--htpps

  首先确保ssl已经添加--编译时带with-http_ssl_module参数
生成证书
  可以通过以下步骤生成一个简单的证书:
  首先,进入你想创建证书和私钥的目录,例如:

[*]$ cd /data/nginx/conf
  创建服务器私钥,命令会让你输入一个口令:

[*]$ openssl genrsa -des3 -out server.key 1024
  创建签名请求的证书(CSR):

[*]$ openssl req -new -key server.key -out server.csr
在加载SSL支持的Nginx并使用上述私钥时除去必须的口令:

[*]$ cp server.key server.key.org
[*]$ openssl rsa -in server.key.org -out server.key
  最后标记证书使用上述私钥和CSR:

[*]$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
  如果是购买的证书,那直接传至服务器某个目录,修改nginx配置文件,添加虚拟主机
  server {
  server_name test.com;
  listen 443;
  indexindex.html index.php;
  root html;
  ssl on ;
  ssl_certificate /data/nginx/conf/server.crt ;
  ssl_certificate_key /data/nginx/conf/server.key;
  ssl_protocols SSLv2 SSLv3 TLSv1;
  ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
  ssl_prefer_server_ciphers   on;
  location / {
  index index.html index.php;
  }
  location ~ .*\.php {
  fastcgi_pass   unix:/tmp/php-cgi.sock;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  https         fastcgi_param HTTPS on;
  include      fastcgi_params;
  }

页: [1]
查看完整版本: nginx--htpps