先去申请https,并将.crt 和 .key文件准备好
server {
listen 80;
server_name i.vxlife.com;
#将请求转成https
rewrite ^(.*)$ https://$host$1 permanent;
}
server {
#SSL 访问端口号为 443
listen 443 ssl;
#填写绑定证书的域名
server_name i.vxlife.com;
#证书文件名称
ssl_certificate /usr//i.vxlife.com_bundle.crt;
#私钥文件名称
ssl_certificate_key /usr//i.vxlife.com.key;
ssl_session_timeout 5m;
#请按照以下协议配置
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}
如果要配置php,如下:
server {
listen 443;
server_name i.vxlife.com;
#证书文件名称
ssl_certificate /usr//i.vxlife.com_bundle.crt;
#私钥文件名称
ssl_certificate_key /usr//i.vxlife.com.key;
ssl_session_timeout 5m;
#请按照以下协议配置
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# 这边的路劲填写项目路劲
root /usr/**/i.vxlife.com/web;
# 记得加上 index.php
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite . /index.php last;
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
# 这边的路劲填写项目路劲
root /usr/**/i.vxlife.com/web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# 要修改为$document_root
fastcgi_param SCRIPT_FILENAME $document_root$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;
#}
}
也可以单独写到一些文件中,然后
http {
include mime.types;
##导入这些conf文件
include ../modules/*.conf;
default_type application/octet-stream;
评论