当前位置:网站首页>Basic knowledge of ngnix
Basic knowledge of ngnix
2022-07-01 22:30:00 【Mwyldnje2003】
reference information :https://www.kuangstudy.com/
nginx brief introduction
Forward and reverse proxies
The agent installed on the client is the forward agent , For example, using vpn etc.
The proxy installed on the server side is the reverse proxy ,
The object of the forward proxy agent is the client , The object of the reverse proxy agent is the server
Load balancing
The request in turn is the round search
iphash Is the solution sessio The problem of session not sharing , Ensure that the data requested by a client is always requested to a fixed server ( It is not recommended to use , In proposal redis)
nginx install
Download address :https://nginx.org/en/download.html
windows Installation in environment
windows Unzip the downloaded file and you can use it directly
You can double-click the startup file , You can also use cmd Command to start
linux Installation in environment
First, install the dependency environment
Automatic configuration nginx
perform make Build
Linux in make, make install What are the commands , usage ?
see ngnix Configuration path
start-up ngnix
nginx Common commands
After modifying the configuration file, you need to reload the configuration file
Firewall open port
Use actual combat
The configuration file
For further reference :Nginx Configuration usage details
Profile explanation
########### Each instruction must have a semicolon end .#################
#user administrator administrators; # Configure users or groups , The default is nobody nobody.
#worker_processes 2; # Number of processes allowed to generate , The default is 1
#pid /nginx/pid/nginx.pid; # Appoint nginx Process running file storage address
error_log log/error.log debug; # Make a log path , Level . This setting can be put into a global block ,http block ,server block , This is the level :debug|info|notice|warn|error|crit|alert|emerg
events {
accept_mutex on; # Set up network connection serialization , To prevent the occurrence of shock , The default is on
multi_accept on; # Set whether a process accepts multiple network connections at the same time , The default is off
#use epoll; # Event driven model ,select|poll|kqueue|epoll|resig|/dev/poll|eventport
worker_connections 1024; # maximum connection , The default is 512
}
http {
include mime.types; # File extension and file type mapping table
default_type application/octet-stream; # Default file type , The default is text/plain
#access_log off; # Cancel service log
log_format myFormat ‘ r e m o t e a d d r – remote_addr– remoteaddr–remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for’; # Custom format
access_log log/access.log myFormat; #combined Default value for log format
sendfile on; # allow sendfile Transfer files by , The default is off, Can be in http block ,server block ,location block .
sendfile_max_chunk 100k; # The number of transfers per process call cannot be greater than the set value , The default is 0, There is no upper limit .
keepalive_timeout 65; # Connection timeout , The default is 75s, Can be in http,server,location block .
upstream mysvr {
server 127.0.0.1:7878;
server 192.168.10.121:3333 backup; # Hot standby
}
error_page 404 https://www.baidu.com; # Error page
server {
keepalive_requests 120; # Maximum number of single connection requests .
listen 4545; # Listening port
server_name 127.0.0.1; # Monitor address
location ~*^.+$ { # Requested url Filter , Regular matching ,~ For case sensitivity ,~* For case insensitive .
#root path; # root directory
#index vv.txt; # Set default page
proxy_pass http://mysvr; # Request turn mysvr List of defined servers
deny 127.0.0.1; # refuse ip
allow 172.18.5.54; # Allow the ip
# expires Set client cache
#expires 1h;
index index.php index.html;
# Resource redirection , Such as visit http://shop.devops.com/index.html It will be rewritten as access http://shop.devops.com/index.php,permanent Indicates permanent redirection
rewrite /index.html /index.php permanent;
# Resource redirection ,$request_filename by nginx Built in variables for , Indicates the resource file path
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
location ~ \.(js|css|jpg|png) {
# Tell the client all js,css,jpg,png Files can be cached 1 Hours , No need to download again on the server
expires 1h;
# Realization of anti-theft chain , All not from shop.devops.com Jump to visit js|css|jpg|png All files are blocked , return 404
valid_referers shop.devops.com;
if ($invalid_referer) {
return 404;
}
}
# php analysis
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
边栏推荐
- MySQL之MHA高可用配置及故障切换
- 中通笔试题:翻转字符串,例如abcd打印出dcba
- 灵动微 MM32 多路ADC-DMA配置
- EasyExcel 复杂数据导出
- The correct way to set the bypass route
- [deep learning] use deep learning to monitor your girlfriend's wechat chat?
- 指标陷阱:IT领导者易犯的七个KPI错误
- Microsoft, Columbia University | Godel: large scale pre training of goal oriented dialogue
- Application of real estate management based on 3D GIS
- 业务可视化-让你的流程图'Run'起来
猜你喜欢
Sonic cloud real machine learning summary 6 - 1.4.1 server and agent deployment
完全注解的ssm框架搭建
[commercial terminal simulation solution] Shanghai daoning brings you Georgia introduction, trial and tutorial
企业架构与项目管理的关联和区别
“丝路正青春 风采看福建”在闽外籍青年短视频大赛火热征集作品中
Pytest Collection (2) - mode de fonctionnement pytest
Training on the device with MIT | 256Kb memory
js如何获取集合对象中某元素列表
名单揭晓 | 2021年度中国杰出知识产权服务团队
keras训练的H5模型转tflite
随机推荐
Business visualization - make your flowchart'run'up
Matlab traverses images, string arrays and other basic operations
测试撤销1
[noip2013] building block competition [noip2018] road laying greed / difference
MIT|256KB 内存下的设备上训练
MySQL清空表数据
IDA动态调试apk
首席信息官对高绩效IT团队定义的探讨和分析
locust 系列入门
EasyExcel 复杂数据导出
【生态伙伴】鲲鹏系统工程师培训
焱融看 | 混合云时代下,如何制定多云策略
Sonic cloud real machine learning summary 6 - 1.4.1 server and agent deployment
Use of vscode
AIDL基本使用
手动实现function isInstanceOf(child,Parent)
I received a letter from CTO inviting me to interview machine learning engineer
PCB线路板塞孔工艺的那些事儿~
MySQL系列之事务日志Redo log学习笔记
[monomer] recommended configuration of streaming information i-bpsv3 server