Skip to main content

nginx 配置 https 请求 支持YII2框架

  1. 先去这个网站申请一下证书
    https://certmall.trustauth.cn/Home/Member/index/id/1521167511.html
    上面会教你怎么去做。
  2. 就是配置自己的nginx了。

    记得这个一定要安装

    yum install openssl openssl-devel

参看下面2个文档。

http://www.cnblogs.com/chen-msg/p/8582374.html http://www.cnblogs.com/chen-msg/p/7754411.html

我们的服务器设置的

server {
listen 443;
server_name dspapi.lzdsp.com;
ssl on;
#charset koi8-r;

access_log logs/dsp-api_access.log;
error_log logs/dsp-api_error.log;
client_max_body_size 20m;
index index.php index.html;
root /home/www/Dsp_api/api/web;
ssl_certificate /usr/local/nginx/conf/ssl/2663127_dspapi.lzdsp.com.pem;
ssl_certificate_key /usr/local/nginx/conf/ssl/2663127_dspapi.lzdsp.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
ssl_prefer_server_ciphers on;
#location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
#{
# expires 30d;
#}
#location ~ .*\.(js|css)?$
#{
# expires 1h;
#}

location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
#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;
#}

location ~ \.php$ {
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

}