当前位置: 首页 > news >正文

Nginx生产环境安装配置

不建议使用nginx-1.18.0.tar.gz,因为扫出很多漏洞

上传nginx-1.24.0.tar.gz

[root@zonghe01 data]# ll
-rw-r--r--  1 root root 1112471 Oct 26 15:57 nginx-1.24.0.tar.gz
[root@zonghe01 data]# pwd
/data

解押

[root@zonghe01 data]# tar -zxvf nginx-1.24.0.tar.gz

配置、编译、安装

[root@zonghe01 data]# cd nginx-1.24.0
[root@zonghe01 nginx-1.24.0]# pwd
/data/nginx-1.24.0
[root@zonghe29 nginx-1.24.0]# ./configure --prefix=/data/nginx24
[root@zonghe29 nginx-1.24.0]# make
[root@zonghe29 nginx-1.24.0]# make install

上传配置文件到指定文件夹下(base.conf、xxx.conf、nginx.conf)

/data/nginx24/conf下建立文件夹config和vhost
[root@zonghe01 config]# ll
total 4
-rw-r--r-- 1 root root 1317 Jun 19 09:01 base.conf
[root@zonghe01 config]# pwd
/data/nginx24/conf/config
[root@zonghe01 config]# cd ../vhost/
[root@zonghe01 vhost]# ll
total 12
-rw-r--r-- 1 root root 2723 Nov 17 10:43 xxx.conf
-rw-r--r-- 1 root root  257 Nov 14 11:08 minio.conf

base.conf文件内容

#配置nginx高效的文件传输模式
sendfile        on;
keepalive_timeout  75s;
#隐藏nginx header版本号,默认为on开启
server_tokens off;
#支持请求头参数的下划线,默认为off关闭,请求中的下划线将会被去掉再不往下传递
underscores_in_headers on;
#设置最大上传文件,默认值为1m,可单独在server,location中设置
client_max_body_size  100m;
#请求头的超时时间,默认60s
client_header_timeout 60s;
client_body_timeout 60s;
#配置缓冲区,线上环境优化重点
proxy_buffering on;
proxy_buffer_size 4k;
proxy_buffers 2 4k;
proxy_busy_buffers_size 4k;
proxy_max_temp_file_size 20M;
proxy_temp_file_write_size 8k;
proxy_connect_timeout 60s;
proxy_read_timeout 1m;
proxy_send_timeout 1m;gzip on;
#gzip_static on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
#gzip_types text/plain application/x-javascript text/css application/xml;
gzip_types text/plain application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg  image/gif image/png;
gzip_vary on;
gzip_proxied   expired no-cache no-store private auth;
gzip_disable   "MSIE [1-6]\.";proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

xxx.conf文件内容

upstream http_res{server xxx.18.xxx.xxx:80;server xxx.18.xxx.xxx:81;server xxx.18.xxx.xxx:82;
}
server {listen       80;server_name xxx.xxx.251.xxx;#location / {#   root   html;#  index  index.html index.htm;#}location  /audit/ {alias /data/web/audit/xxx_web/;index index.html /data/web/audit/xxx_web/index.html;}location /minio/ {#proxy_http_version 1.1;#proxy_set_header Upgrade $http_upgrade;#proxy_set_header Connection "upgrade";#proxy_set_header   Host 172.19.57.11;  		proxy_pass http://127.0.0.1:9001/;}location /api2/ {proxy_pass http://http_res;proxy_http_version 1.1;proxy_set_header   Host $http_host;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}location /api/ {proxy_pass http://http_res;proxy_http_version 1.1;proxy_set_header   Host $http_host;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}}

nginx.conf文件内容

user  root;
# 跟服务器核数相同
worker_processes  8;events {worker_connections  4096;#worker_rlimit_nofile 65535;
}http {include       mime.types;default_type  application/octet-stream;include config/base.conf;server_names_hash_bucket_size 64;charset utf-8;send_timeout 120s;# 读取vhost下所有.conf文件include vhost/*.conf;
}

启动、停止、重启

[root@zonghe02 conf]# /data/nginx24/sbin/nginx
[root@zonghe02 conf]# /data/nginx24/sbin/nginx -s stop
[root@zonghe02 conf]# /data/nginx24/sbin/nginx -s reload
http://www.lryc.cn/news/236852.html

相关文章:

  • 「项目阅读系列」go-gin-example star 6.5k!(1)
  • 基于轻量级yolov5的瓷砖瑕疵检测系统
  • Linux:系统基本信息扫描(2)
  • 什么是虚拟DOM(Virtual DOM),说说工作原理
  • Kafka的重要组件,谈谈流处理引擎Kafka Stream
  • 基于yolov5模型的200种鸟类检测识别分析系统
  • JavaScript的学习,就这一篇就OK了!(超详细)
  • hive sql 取当周周一 str_to_date(DATE_FORMAT(biz_date, ‘%Y%v‘), ‘%Y%v‘)
  • 【React】React 基础
  • CentOS7 设置 nacos 开机启动
  • 使用低代码可视化开发平台快速搭建应用
  • 数据分析思维与模型:多维度拆解分析法
  • Goby 漏洞发布|大华智慧园区综合管理平台 poi 文件上传漏洞
  • 视频修复软件 Aiseesoft Video Repair mac中文版功能
  • 企业spark案例 —— 出租车轨迹分析(Python)
  • SQL Server - 使用 Merge 语句实现表数据之间的对比同步
  • 【Web】Flask|Jinja2 SSTI
  • SPDK NVMe-oF target多路功能介绍
  • ADAudit Plus:助力企业安全的权威选择
  • sqli-labs关卡18(基于http头部报错盲注)通关思路
  • uni-app顶部导航栏背景色如何设置,微信小程序返回键设置
  • 基于多种设计模式重构代码(工厂、模板、策略)
  • boomYouth
  • 关于这个“这是B站目前讲的最好的【Transformer实战】教程!“视频的目前可以运行的源代码GPU版本
  • STM32定时器输入捕获测量高电平时间
  • 开源WIFI继电器之硬件电路
  • 远程执行ssh脚本
  • excel导入 Easy Excel
  • html实现图片裁剪处理(附源码)
  • 前端语言报错