#腾讯云证书文档 https://cloud.tencent.com/document/product/400/4143
备注,手动编译安装须要安加入 SSL 模块(http_ssl_module)php
server { # 开启https端口 listen 443 ssl; # 填写绑定证书的域名 server_name xxx.com; # nginx的错误日志 access_log /var/log/nginx/sd-access.log; error_log /var/log/nginx/sd-error.log; # 默认网站根目录 root /data/releases/websites/sd/htdocs; # 将如下路由下放到前台 location ~ (^/taskm)|(^/perm)|(^/data) { try_files $uri /index.html; } location / { # 入口文件,注意这里有前后顺序 index index.html index.php index.htm; if (!-e $request_filename) { rewrite . /index.php last; } } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # https证书配置 # 开启ssl ssl on; # 证书文件 ssl_certificate /usr/local/nginx/conf/ssl/xxxx.crt; # 私钥文件 ssl_certificate_key /usr/local/nginx/conf/ssl/xxxx.key; # 配置会话超时时间 ssl_session_timeout 5m; # 配置共享会话缓存大小 ssl_session_cache shared:SSL:10m; # ssl_protocols 和 ssl_ciphers 用来限制链接只包含 SSL/TLS 的加強版本和算法 # 配置协议 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # 配置加密套件 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; # 优先采起服务器算法 ssl_prefer_server_ciphers on; # Fastcgi服务器和程序(PHP,Python)沟通的协议. location ~ \.php$ { # 设置监听端口 fastcgi_pass 127.0.0.1:9000; # 设置nginx的默认首页文件,上面index设置过 fastcgi_index index.php; # 设置脚本文件请求的路径 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # 引入fastcgi的配置文件 include fastcgi_params; fastcgi_param SERVER_NAME $http_host; fastcgi_ignore_client_abort on; fastcgi_connect_timeout 600s; fastcgi_send_timeout 600s; fastcgi_read_timeout 600s; } # 对图片缓存时间设置 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ { expires 30d; access_log off; } # 对JS和CSS缓存时间设置 location ~ .*\.(js|css)?$ { expires 7d; access_log off; } } # 使用全站加密,HTTP 自动跳转 HTTPS, 注意配置这里上面就不能再监听80端口 server { # 80端口访问 listen 80; # 配置访问域名 不包含协议 server_name xxx.com; # 使用url重写模块重写url 访问非https的url重定向到http上去 rewrite ^/(.*) https://$host/$1 permanent; }