nginx快速配置参考
基本命令:
一、启动
cd usr/local/nginx/sbin
./nginx
二、重启
更改配置重启nginx
kill -HUP 主进程号或进程号文件路径 或者使用
cd /usr/local/nginx/sbin
./nginx -s reload
判断配置文件是否正确
nginx -t -c /usr/local/nginx/conf/nginx.conf 或者
cd /usr/local/nginx/sbin ./nginx -t
yum install gcc pcre-devel zlib-devel openssl-devel libxml2 libxslt perl-ExtUtils-Embed unzip
groupadd nginx
useradd -s /sbin/nologin -g nginx nginx
unzip nginx-module-vts-master.zip
unzip nginx-sticky-module-ng.zip
tar -zxvf nginx-1.19.6.tar.gz
cd /home/hsmt/nginx
unzip nginx-module-vts-master.zip
unzip nginx-sticky-module-ng.zip
tar -zxvf nginx-1.19.6.tar.gz
ls
mv nginx-goodies-nginx-sticky-module-ng-08a395c66e42 nginx-sticky
mv nginx-module-vts-master nginx-vts
cd nginx-1.19.6
./configure --prefix=/app/nginx --user=nginx --group=nginx --with-http_stub_status_module --add-module=../nginx-vts --with-http_ssl_module --add-module=../nginx-sticky --with-http_realip_module
make && make install
cd /app/nginx
ls
cd conf
ls
df -h
cd /app/nginx/conf
vi parameters.conf
ls
mv nginx.conf nginx.conf.old
vi nginx.conf
cd ../html
ls
vi index.html
cp index.html 404.html
../nginx -t
../sbin/nginx -t
../sbin/nginx -s start
版本:
[root@localhost sbin]# ./nginx -V
nginx version: nginx/1.19.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
built with OpenSSL 1.0.2s 28 May 2019 (running with OpenSSL 1.0.2k-fips 26 Jan 2017)
TLS SNI support enabled
configure arguments: --prefix=/app/nginx --user=nginx --group=nginx --with-http_stub_status_module --add-module=../nginx-vts-module --with-http_ssl_module --add-module=../nginx-sticky-module --with-http_realip_module
参数配置:
[root@app conf]# cat parameters.conf
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
[root@app conf]# cat nginx.conf
#user nobody;
user root;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 4096;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main
'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8888;
server_name localhost;
charset utf-8;
client_max_body_size 20M;
client_body_buffer_size 2M;
error_log logs/error.log error;
access_log logs/host.access.log;
error_page 500 502 503 504 404 /404.html;
location = /404.html {
root /app/nginx/html;
}
location / {
root /app/apache-tomcat-7.0.107;
proxy_pass http://192.168.10.176:8080/;
proxy_intercept_errors on;
include parameters.conf;
}
location /test1 {
root /app/test2/;
proxy_pass http://192.168.10.176:9999/test1;
include parameters.conf;
}
location /test2 {
proxy_pass http://10.119.126.166:9000/test2;
include parameters.conf;
}
}
}
[root@app conf]#
nginx快速配置参考相关推荐
- nginx快速配置自签SSL域名证书
缺德地图持续迷路中 简单说明 CSR文件生成网站 制作CA自签证书 测试nginx安装 访问测试 Linux主机访问测试 windows主机访问测试 简单说明 在制作证书之前,先简单说明一下关于制作域 ...
- Centos7.x快速配置Django+Nginx+Uwsgi服务
大家好,我是Mr数据杨.今天,将和大家分享如何构建一个完善的服务器环境.折磨了我2天,终于自己调试成功Django+nginx+uwsgi的服务,直接上流程按照这个流程100%能成功,就算你啥也不懂看 ...
- nginx技术(2)nginx的配置详解
nginx的配置 1,启动nginx 1 2 3 4 5 6 7 [root@centos6 nginx-1.2.9]# /usr/sbin/nginx -c /etc/nginx/nginx.con ...
- Nginx伪静态配置和常用Rewrite伪静态规则集锦
伪静态是一种可以把文件后缀改成任何可能的一种方法,如果我想把php文件伪静态成html文件,这种相当简单的,下面我来介绍nginx 伪静态配置方法 nginx里使用伪静态是直接在nginx.conf ...
- 巧用 Nginx 快速实现 HTTPS 双向认证
1.原理 双向认证,顾名思义,客户端和服务器端都需要验证对方的身份,在建立 HTTPS 连接的过程中,握手的流程比单向认证多了几步.单向认证的过程,客户端从服务器端下载服务器端公钥证书进行验证,然后建 ...
- nginx的工作原理与nginx的配置
1.nginx的工作原理 nginx的模块直接被编译进nginx,因此属于静态编译方式. 启动nginx后,nginx的模块被自动加载,与Apache不一样,首先将模块编译为一个so文件,然后在配置文 ...
- nginx 使用配置解释
nginx 安装 安装依赖 下载 编译安装 编译时将 ssl 模块静态编译 nginx 服务架构 模块化结构 模块化开发 nginx 的模块化结构 nginx 的模块清单 nginx 的 web 请求 ...
- NGINX免费配置二级域名及同时开启HTTPS(HTTP强制转HTTPS)nodejs的express后端项目,前端next.js的SSR项目
最近在做web3的创业项目,需要给第三方提供API接口需要配置二级域名:整个过程遇到了一系列问题都一一解决了,记录下整个过程: 二级域名是可以不开启HTTPS的,直接用HTTP也行,开启HTTPS后配 ...
- Nginx安装配置和常用使用(反向代理与负载均衡)
文章目录 1.Ubuntu服务器中的nginx 2.Mac中使用nginx 3.配置不同的域名访问项目不需要输入端口方式 4.ssl配置 5.nginx 禁止 ip 允许和阻止访问 6.自定义403等 ...
最新文章
- 积极拥抱.NET Core开源社区
- 转载:土豆洋芋山药蛋的博客: SBSE—基于搜索的软件工程简介
- Python进程和线程保姆式教学,1个台机子多只手干活的秘籍
- Thinkpad在Windows8上热键的解决方案
- awk bc命令 linux_linux之awk命令(转载)
- 分布式系统监控系统zipkin入门
- 网络流及建模专题(上)
- C++学习:两个vector对象拼接
- 博文写作——摘要摘要图标
- 18kw丹佛斯变频器常见故障_变频器常见故障——输出不平衡、过载、开关电源损坏...
- 如何设置mysql的运行目录_如何修改mysql数据库文件的路径 | 学步园
- 距离之和最小 V3 51Nod - 1110(带权中位数或者爆搜)
- 在计算机操作系统中操作系统是处于应用软件,计算机操作系统考试复习题
- 【毕业设计选题】C51单片机毕业设计题目推荐大全
- 《巴菲特的第一桶金》读书笔记
- 微软苏州2018冬季实习面试经历
- 市面上最流行的九大现场总线
- 一键怎样批量修改图片像素大小
- HDFS Shell 命令简介及查询
- 公告模块phpcms