常规nginx配置

  1 server
  2     {
  3         listen 80;
  4         listen 443 ssl http2;
  5         server_name ;
  6         index index.php index.html index.htm default.php default.htm default.html;
  7         root /home/wwwroot/site/public;
  8 
  9         #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
 10         #error_page 404/404.html;
 11         #HTTP_TO_HTTPS_START
 12         if ($server_port !~ 443){
 13             rewrite ^(/.*)$ https://$host$1 permanent;
 14         }
 15         #HTTP_TO_HTTPS_END
 16         ssl_certificate    /usr/local/nginx/conf/ssl/2111622_mini.szzonv.com.pem;
 17         ssl_certificate_key    /usr/local/nginx/conf/ssl/2111622_mini.szzonv.com.key;
 18         ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
 19         ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
 20         ssl_prefer_server_ciphers on;
 21         ssl_session_cache shared:SSL:10m;
 22         ssl_session_timeout 10m;
 23         error_page 497  https://$host$request_uri;
 24 
 25 
 26 
 27         #SSL-END
 28         
 29         #ERROR-PAGE-START  错误页配置,可以注释、删除或修改
 30         error_page 404 /404.html;
 31         error_page 502 /502.html;
 32         #ERROR-PAGE-END
 33         
 34         #PHP-INFO-START  PHP引用配置,可以注释或修改
 35         include enable-php.conf;
 36         #PHP-INFO-END
 37         
 38         #REWRITE-START URL重写规则
 39         location / {
 40             index  index.html index.htm index.php;
 41             #autoindex  on;
 42             if (!-e $request_filename){
 43               rewrite  ^(.*)$  /index.php?s=$1  last;
 44               break;
 45             }
 46         }
 47         #REWRITE-END
 48         location ~ \.php(.*)$ {
 49                 fastcgi_pass   127.0.0.1:9000;
 50                 fastcgi_index  index.php;
 51                 fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
 52                 fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
 53                 fastcgi_param  PATH_INFO  $fastcgi_path_info;
 54                 fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
 55                 #include        fastcgi_params;
 56                 fastcgi_param  PHP_VALUE  "open_basedir=/home/wwwroot/zn/:/tmp/:/proc/";
 57             }
 58         #禁止访问的文件或目录
 59         location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
 60         {
 61             return 404;
 62         }
 63         
 64         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
 65         {
 66             expires      30d;
 67             error_log off;
 68             access_log /dev/null;
 69         }
 70         
 71         location ~ .*\.(js|css)?$
 72         {
 73             expires      12h;
 74             error_log off;
 75             access_log /dev/null; 
 76         }
 77     }
 78 
 79     server
 80     {
 81         listen 80 default_server;
 82         #listen [::]:80 default_server ipv6only=on;
 83         server_name ac.twsliot.cn;
 84         index index.html index.htm index.php;
 85         root  /home/wwwroot/ssj/public;
 86 
 87         #error_page   404   /404.html;
 88 
 89         # Deny access to PHP files in specific directory
 90         #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
 91 
 92         include enable-php.conf;
 93 
 94         #REWRITE-START URL重写规则
 95         location / {
 96             index  index.html index.htm index.php;
 97             #autoindex  on;
 98             if (!-e $request_filename){
 99               rewrite  ^(.*)$  /index.php?s=$1  last;
100               break;
101             }
102         }
103 
104         #禁止访问的文件或目录
105         location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
106         {
107             return 404;
108         }
109         location /nginx_status
110         {
111             stub_status on;
112             access_log   off;
113         }
114 
115         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
116         {
117             expires      30d;
118         }
119 
120         location ~ .*\.(js|css)?$
121         {
122             expires      12h;
123         }
124 
125         location ~ /.well-known {
126             allow all;
127         }
128 
129         location ~ /\.
130         {
131             deny all;
132         }
133 
134         access_log  /home/wwwlogs/twsliot.cn_access.log;
135     }

猜你喜欢

转载自www.cnblogs.com/codeninja/p/12027637.html