分类目录归档:Nginx

produced an unexpected error: ‘ascii’ codec can’t decode byte 0xe9 in position

把配置文件里的中文字符串删除就好了

  1. $ sudo grep -r -P ‘[^\x00-\x7f]’ /etc/apache2 /etc/letsencrypt /etc/nginx
  2. 將看到的內容,全部進去檔案刪除
  3. 刪除這些編碼後,在重新執行 Let’s encrypt script 就可以通過囉~
Attempting to renew cert (www.xxx.com) from /etc/letsencrypt/renewal/www.xxx.com.conf produced an unexpected error: 'ascii' codec can't decode byte 0xe9 in position 5: ordinal not in range(128). Skipping.
All renewal attempts failed. The following certs could not be renewed:
  /etc/letsencrypt/live/m.xxx.com/fullchain.pem (failure)
  /etc/letsencrypt/live/www.xxx.com/fullchain.pem (failure)

参考链接:https://blog.longwin.com.tw/2019/01/letsencrypt-ascii-codec-decode-fixed-2019/

nginx: [warn] duplicate MIME type “text/html”

我检查配置文件发现疑似gzip漏写了text/html,加上去后反而报警告了,百度发现:

https://blog.csdn.net/liangyuannao/article/details/21378113

解决办法:去掉下面一行中的“text/html”。

gzip_types  text/plain text/html  text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

原因:text/html根本就不需要写的,gzip默认就会压缩它的,只不过以前的nginx版本不提示这个警告而已,新版本的会出这个警告。

laravel 获取真实ip的事项

# 这个逻辑可以放在中间件里,判断白名单(127.0.0.1或你的其他代理服务器ip)
$ip = $request->ip();
        if (in_array($ip, ['127.0.0.1']))
            $request->setTrustedProxies($request->getClientIps(), Request::HEADER_X_FORWARDED_ALL);

# nginx 配套配置,如果你是nginx转发,按照这个标准来
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;


# 获取IP
echo $request->ip();

X-Forwarded-For 相关连接:https://en.wikipedia.org/wiki/X-Forwarded-For

ab压力测试

apr_socket_recv: Connection reset by peer:
https://www.cnblogs.com/archoncap/p/5883723.html

ulimit解除: https://blog.51cto.com/853056088/2091839

2019/05/03 07:43:36 [crit] 27684#27684: accept4() failed (24: Too many open files):
worker_rlimit_nofile 51200;

selinux 解除:
2019/05/03 07:46:07 [alert] 43314#43314: setrlimit(RLIMIT_NOFILE, 10000) failed (1: Operation not permitted)
setsebool -P httpd_setrlimit 1

php开启opcache可以提升80%左右qps
[root@abcdocker ~]# tail /etc/php.ini 
zend_extension="opcache.so"