Code前端首页关于Code前端联系我们

Linux基础运维优化及Nginx缓存构建

terry 2年前 (2023-09-28) 阅读数 62 #未命名

Linux基础运维优化

  • SSH端口修改、禁用密码登录、更改私钥登录
  • Iptables防火墙配置优化
  • 最大监控文件数
  • 最大打开文件数
  • 安装其他软件

Nginx优化配置

  • SSL证书导入
  • 配置优化
  • 日志存储天数logrotate.d

user nginx;
worker_processes 2;
worker_rlimit_nofile 60000;
error_log /var/log.log/nginx/d ginx .pid;
事件{ worker_connections 102400;
}

http {
包括/etc.oc.nginx/mi;
log_format主'$remote_addr - $remote_user [$time_local]“$request”$status$body_bytes_sent“$ http_referer ” “$http_user_agent” “$http_x_forwarded_for”';
access_log /var/log/logginx/access. sendfile on;
keepalive_timeout 300s;
include /etc/nginx/conf.d/*.conf;
server_tokens off;_ server_max;2s5 server_names_hash_bucket_size 1 28;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
gzip 打开;
gzip_disable msie6;
gzip_min_length 1k;p gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_proxied evt。 ;
gzip_varies on;
gzip_types 文本/纯文本xt/css 文本/xml 文本/javascript 文本/x-组件应用程序/json 应用程序/javascript 应用程序/xml 应用程序/xhtml+xml 应用程序/xml+rss 应用程序/rss+xml 应用程序/atom+xml 应用程序/x-font-ttf application/x-web-app-manifest+json 字体/opentype 图像/svg+xml 图像/x-icon;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;_ fast_cgi_buffers 8 fastcgi_temp_file_write_size 256k;
client_max_body_size 10m;
proxy_connect_timeout 10;
proxy_read_timeout 180;
proxy_send_timeout 30;send_buffers proxy_buffers 8 64k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_temp_path /data/cache/temp;
proxy_cache_path /data/cache/cache_files level=1:2 keys_zone=cache_one:100m inactive=1d max_size=10g; 配置 位置 ~* \ .(js|css|jpg|png|gif|txt)$ {
proxy_pass https://www.baidu.com;
proxy_set_header 主机 $host;
proxy_set_header X-真实IP $remote_addr;
proxy_redirect from;
proxy_cache cache_one;
proxy_cache_key $host$uri$is_args$args;_ 2_0 valid 1
proxy_cache_valid any 1m; 6 小时失效;
add_header |Mobile)') {
重写 ^.+ https://m.baidu.com$uri permanent;
}

proxy_pass。 https://www.bai_du。 en

位置 ~ \. php$ {
proxy_pass https://m.baidu.com;
proxy_set_header 主机$host;
proxy_set_header X-真实IP $remote_addr;
}

版权声明

本文仅代表作者观点,不代表Code前端网立场。
本文系作者Code前端网发表,如需转载,请注明页面地址。

热门