- nginx优化–系统内核
1 | 关于内核参数的优化: |
nginx优化–配置文件
1 | worker_processes 8; |
nginx做proxy代理 上传下载文件大小有限制,主要配置
proxy_buffer_size proxy_buffers``` 1
2
3
4
5
6
7
8
9
10
11
12
13
14
```nginx
location / {
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 120s;
proxy_read_timeout 120s;
proxy_send_timeout 120s;
client_max_body_size 100m; ##配置上传下载文件大小
proxy_buffer_size 128k; ##配置缓存大小
proxy_buffers 100 ; ##配置缓存个数,缓存大小等于100*128k
}配置nginx+php5.4的时候,配置完成后,浏览器打开php文件就提示File not found.错误。
纠结半天,终于发现错误的地方了:1
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
改成如下这句,即可
1
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
1
2
3
4
5
6
7
8
9
10
11
12
13
14server {
listen 80;
server_name www.example.com;
root /home/nginx/vhosts/example.com/web;
location / {
index index.php;
}
location ~ \.php$ {
root /home/nginx/vhosts/example.com/web;
fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
nginx 编译安装完启动出现
Can’t load ‘/usr/local/lib64/perl5/auto/nginx/nginx.so’ for module nginx: /usr/local/lib64/perl5/auto/nginx/nginx.so: undefined symbol: ngx_http_perl_handle_request at /usr/share/perl5/XSLoader.pm line 68.
nginx 启动 nginx: [alert] perl_parse() failed: 255
1 | 解决办法 |
- nginx做文件服务器配置示例
1 | server { |
- nginx https和转发最佳配置配置示例
1 | ## Apache backend for apsec.mitake.com.cn ## |
Nginx基于端口,端口不能随页面跳转
利用nginx做反向代理,login页面能正常转发到,输入账号密码后,点击登陆就发现url代理少了端口,解析不到登录后的页面
解决办法:
在 proxy_set_header Host $host;
加转发的端口号proxy_set_header Host $host:8889;
1 | [root@localhost conf.d]# cat example.conf |
Nginx 跨域请求配置示例
1 | server { |
http强制转换https,解决wss 400错误
1 | server { |
- 本文作者: ChuLinx
- 本文链接: http://yoursite.com/2020/06/19/一文总结nginx常见用法及故障/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!