美文网首页
Nginx的Https配置

Nginx的Https配置

作者: henryspace | 来源:发表于2017-05-04 22:43 被阅读0次

一,准备工作

  • 证书秘钥,推荐Freessl
  • Nginx服务器

二,修改配置文件

1,ssl配置文件ssl.conf

server {
    listen       443;
    server_name  yourdomain.com;
    ssl on;
    #your project path
    root         /www/trunk;

    ssl_certificate   /etc/cert/yoursignature.pem;
    ssl_certificate_key  /etc/cert/yoursignature.key;
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  10m;
    #you need to modify yourfingerprint
    ssl_ciphers yourfingerprint;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    # Load configuration files for the default server block.
    # include /etc/nginx/default.d/*.conf;

    location / {
        root   /www/trunk;
        index  index.php index.html index.htm;
    }

    error_page 404 /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /www/trunk;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /www/trunk$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }
}

2,修改nginx默认配置default.conf

server {  
    listen  80;  
    server_name yourdomain.com;  
      
    rewrite ^(.*)$  https://$host$1 permanent;  
}

三,重启nginx

systemctl restart nginx.service

相关文章

  • # nginx https证书配置

    nginx https证书配置 一 前言 此文档针对于nginx配置反向代理使用https证书方法 nginx作为...

  • nginx配置https

    nginx配置https https需要的证书我们已经申请到了,下面分享下nginx配置https的一些配置参数!...

  • Nginx配置https请求,以及Nginx+keepalive

    一、Nginx配置https请求 要实现Nginx配置https请求,安装的时候需要加上 --with-http_...

  • nginx https 配置

    nginx https 配置

  • nginx配置https

    只配置443会导致http和https共存,只要再80里配置个重定向即可return 301 https://$s...

  • nginx https配置

    本地文件上传到服务器

  • Nginx https 配置

    准备环境阿里云 腾讯云部署好站点,且使用DNS解析到云服务器的IP地址 接下来就是配置HTTPS的关键步...

  • Nginx配置HTTPS

  • Nginx 配置 https

    从云服务提供商处申请证书 申请 https 证书教程-百度经验 申请下来的证书目录结构 下文中只拿 Nginx 来...

  • NGINX 配置 HTTPS

    首先是下载证书,我的是再阿里云里面,如果购买成功了,直接下载证书。里面会有两后缀分别为.key和.pem的个文件,...

网友评论

      本文标题:Nginx的Https配置

      本文链接:https://www.haomeiwen.com/subject/mtadtxtx.html