首页 > 系统相关 >Nginx V1.20.1部署

Nginx V1.20.1部署

时间:2023-06-07 10:48:25浏览次数:60  
标签:sbin http nginx -- module V1.20 Nginx 部署 usr

https://mp.weixin.qq.com/s/i8XmjuW9yRXwqtiSvACpxg

# 下载二进制安装包
wget http://nginx.org/download/nginx-1.20.1.tar.gz
# 解压
tar zxvf nginx-1.20.1.tar.gz
cd nginx-1.20.1
# 安装依赖包
yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel gd-devel gb
# 安装所需模块
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_image_filter_module --with-ipv6 --with-stream --with-http_v2_module --with-http_flv_module

==创建用户组==
/usr/sbin/groupadd -f nginx && /usr/sbin/useradd -g nginx nginx


# 如果报错则需要安装gb
yum -y install gd-devel gb

make && make install

# 创建软链接
$ ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx


# 启动nginx
$ nginx

# 卸载nginx
yum erase nginx -y


rm -rf /usr/local/nginx /usr/local/nginx/sbin/nginx /usr/share/nginx /usr/sbin/nginx /var/spool/mail/nginx

yum erase keepalived nginx -y
# 搜索文件夹
find / -name nginx
cat > /usr/local/nginx/conf/nginx.conf << "EOF"
user nginx;
worker_processes auto;
error_log /usr/local/nginx/logs/error.log;
pid /usr/local/nginx/logs/nginx.pid;

events {
worker_connections 1024;
}

http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
map $status $loggable {
~^[23] 0;
default 1;
}
access_log /usr/local/nginx/logs/access.log combined if=$loggable buffer=512k flush=1m;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_types application/xml
application/json
text/css
text/javascript
application/javascript;
gzip_vary on;
gzip_comp_level 6;
gzip_min_length 500;
keepalive_timeout 65;
types_hash_max_size 2048;
include mime.types;
default_type application/octet-stream;

server {
listen 80 default_server;
server_name _;

location / {
}

location ~* \.(?:jpg|jpeg|gif|png|ico|woff2|js|css)$ {
access_log off;
}
}
include vhost/*.conf;
}
EOF
/usr/sbin/groupadd -f nginx
/usr/sbin/useradd -g nginx nginx


cat > /usr/local/nginx/conf/nginx.conf << "EOF"
user nginx;
worker_processes auto;
error_log /usr/local/nginx/logs/error.log;
pid /usr/local/nginx/logs/nginx.pid;

events {
worker_connections 1024;
}

# 四层负载均衡,为两台Master apiserver组件提供负载均衡
stream {

log_format main '$remote_addr $upstream_addr - [$time_local] $status $upstream_bytes_sent';

access_log /usr/local/nginx/logs/k8s-access.log main;

upstream k8s-apiserver {
server 172.30.0.14:6443; # Master1 APISERVER IP:PORT
server 172.30.0.8:6443; # Master2 APISERVER IP:PORT
}

server {
listen 6443; # 由于nginx与master节点复用,这个监听端口不能是6443,否则会冲突
proxy_pass k8s-apiserver;
}

}

http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
map $status $loggable {
~^[23] 0;
default 1;
}
access_log /usr/local/nginx/logs/access.log combined if=$loggable buffer=512k flush=1m;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_types application/xml
application/json
text/css
text/javascript
application/javascript;
gzip_vary on;
gzip_comp_level 6;
gzip_min_length 500;
keepalive_timeout 65;
types_hash_max_size 2048;
include mime.types;
default_type application/octet-stream;
gzip on; # 开启Gzip
gzip_min_length 500;
gzip_buffers 4 8k;
gzip_comp_level 6;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";  # ie6不提供gzip
gzip_proxied any;
gzip_vary on;
gzip_static on;  # 如果有压缩好的,直接使用
gzip_types text/plain text/xml text/css text/javascript application/json application/javascript application/x-javascript application/xml image/jpeg image/gif image/png;
types_hash_max_size 2048
include vhost/*.conf;
}
EOF

标签:sbin,http,nginx,--,module,V1.20,Nginx,部署,usr
From: https://www.cnblogs.com/zengdingding/p/17462487.html

相关文章

  • 如何在nginx.conf中使用系统的环境变量(env)?
    一、需求 如果在nginx的配置中,想要使用系统中,已经存在的环境变量的值,然后在后面的配置中使用这个变量的值,在系统中的这个变量,可以是动态变化的,比如pod的名字,这个环境变量,在每次pod的启动的时候,都会会发生变化的 那么,有什么办法来实现这个需求呢? 通过使用lua模块,来实现。......
  • docker 部署db2
    拉取镜像dockerpullibmcom/db2:11.5.8.0启动db2dockerrun-d-p50000:50000--namedb2--privileged=true-eDB2INSTANCE=test-eDB2INST1_PASSWORD=123456-eDBNAME=testdb-eLICENSE=acceptibmcom/db2:11.5.8.0dockerrun-d在后台启动容器-p50000:50000......
  • Nginx出现403 forbidden (13: Permission denied)报错的解决办法
    一、由于启动用户和nginx工作用户不一致所致1、将nginx.config的user改为和启动用户一致,命令:viconf/nginx.conf二、缺少index.html或者index.php文件,就是配置文件中indexindex.htmlindex.htm这行中的指定的文件。server{listen80;server_namelocalhost;indexindex.p......
  • k8s实战案例之部署redis单机和redis cluster
    1、在k8s上部署redis单机1.1、redis简介redis是一款基于BSD协议,开源的非关系型数据库(nosql数据库),作者是意大利开发者SalvatoreSanfilippo在2009年发布,使用C语言编写;redis是基于内存存储,而且是目前比较流行的键值数据库(key-valuedatabase),它提供将内存通过网络远程共享的一种服......
  • Kafka 单机部署搭建及其基本使用
    最近在搞Flink框架其中数据源需要模拟kafka取数据,于是自己搭建了一套单机的kafka环境,以便用于测试。现整理如下的笔记,发上来和大家分享。后续还会有kafka的相关笔记,会与大家继续分享!当前文档所部署服务器IP地址为192.168.118.218hostname为web一、kafka环境搭建下载kafka......
  • nginx location带@
    目录nginxlocation带@nginxlocation带@我想访问https://dev-das.aaa.com/@config和https://dev-das.aaa.com/config的时候都能跳转到后端location~*/@?config{proxy_redirectoff;set$Real$proxy_add_x_forwarded_for;if($Real......
  • 自动部署信息采集脚本
    为了满足定制化需求,特对物理主机的多路径软件multipath服务和路径进行了脚本采集,并提供自动化部署路径。1、多路径采集脚本#!/bin/bash#resultincludevalid_num\invalid_num\source/etc/profile##获取ip地址bond1=`ipaddressshowdevbond1|grep172.29|awk-F"/"'{......
  • Nginx漏洞修复:SSL/TLS 服务器瞬时 Diffie-Hellman 公共密钥过弱
    SSL/TLS服务器瞬时Diffie-Hellman公共密钥过弱【原理扫描】。需编辑nginx.conf解决。1、生成dhparams.pem。cd/usr/local/nginx/confopenssldhparam-outdhparams.pem2048chmod-R755dhparams.pem2、编辑nging.conf文件,添加ssl_dhparam{pathto......
  • docker 操作nginx命令+docker-compose常用命令及yml文件编写
    docker-compose常用命令及yml文件编写https://blog.csdn.net/doubiy/article/details/118997661 https://docs.docker.com/compose/1.观察下载容器镜像过程dockerrun-dnginx:latest-d表示当前终端的后台运行nginx:latest就是最新的nginx版本2.访问容器中的ngi......
  • nginx代理webSocket 和eventSource 相关配置
    文章转载自: https://blog.csdn.net/Embrace924/article/details/92649471nginx代理webSocket和eventSource请求超时连接不通但是本地可以nginx代理出了问题不能普通代理一样要先发起普通请求代理然后通过一些属性再次转换#常用配置location/api/{    proxy_pas......