1. HTTPS server
  2. server {
  3. listen 443;
  4. server_name localhost;
  5. ssl on;
  6. ssl_certificate cert.pem;
  7. ssl_certificate_key cert.key;
  8. ssl_session_timeout 5m;
  9. ssl_protocols SSLv2 SSLv3 TLSv1;
  10. ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
  11. ssl_prefer_server_ciphers on;
  12. location / {
  13. }
  14. }

  1. server {
  2. listen 443;
  3. server_name localhost;
  4. ssl on;
  5. root html;
  6. index index.html index.htm;
  7. ssl_certificate /usr/local/nginx/conf/cert/www.baidu.com.pem;
  8. ssl_certificate_key /usr/local/nginx/conf/cert/www.baidu.com.key;
  9. ssl_session_timeout 5m;
  10. ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  11. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  12. ssl_prefer_server_ciphers on;
  13. location / {
  14. root html;
  15. index index.html index.htm;
  16. }
  17. }

 

  1. server
  2. {
  3. listen 80;
  4. server_name www.baidu.com baidu.com;
  5. index index.html index.htm index.php default.html default.htm default.php;
  6. root /home/www/baidu;
  7. return 301 https://www.baidu.com$request_uri;
  8. }

 

  1. #-------gzip conf-----
  2. gzip on;
  3. gzip_min_length 1k;
  4. gzip_buffers 4 16k;
  5. #gzip_http_version 1.0;
  6. gzip_comp_level 6;
  7. gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
  8. gzip_vary off;
  9. gzip_disable "MSIE [1-6]\.";

 

基本只需要更改gzip_comp_level等级,1-9,等级越高压缩率越高,但相应也越耗CPU资源,一般不会设置可以折中为6.

6、重启nginx服务
  1. ./nginx -s reload
  2. systemctl nginx restart

 

  1.  

版权声明:本文为roes原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/roes/p/10406270.html