当前位置:网站首页>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;
}
}
}
边栏推荐
- ICML2022 | 基于元语义正则化的介入性对比学习
- Basic operation of binary tree
- Airserver mobile phone third-party screen projection computer software
- “丝路正青春 风采看福建”在闽外籍青年短视频大赛火热征集作品中
- JS how to get a list of elements in a collection object
- mysql 学习笔记-优化之SQL优化
- Tops, the unit of computing power of the processor, can be carried out 1 trillion times per second
- CNN卷积神经网络原理讲解+图片识别应用(附源码)[通俗易懂]
- [monomer] recommended configuration of streaming information i-bpsv3 server
- Redis配置与优化
猜你喜欢
Application of real estate management based on 3D GIS
List announced | outstanding intellectual property service team in China in 2021
手动实现function isInstanceOf(child,Parent)
【MySQL】explain的基本使用以及各列的作用
Sonic云真机学习总结6 - 1.4.1服务端、agent端部署
详解ThreadLocal
Little p weekly Vol.11
mysql 学习笔记-优化之SQL优化
Copy ‘XXXX‘ to effectively final temp variable
[deep learning] use deep learning to monitor your girlfriend's wechat chat?
随机推荐
Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
MySQL系列之事务日志Redo log学习笔记
List announced | outstanding intellectual property service team in China in 2021
地图其他篇总目录
MIT|256KB 内存下的设备上训练
函数基本学习之一
物联网rfid等
Basic operation of binary tree
Do you want to make up for the suspended examination in the first half of the year? Including ten examinations for supervision engineers, architects, etc
Make a three digit number of all daffodils "recommended collection"
按照功能对Boost库进行分类
【MySQL】数据库优化方法
pytest合集(2)— pytest运行方式
Electron学习(三)之简单交互操作
Fundamentals - IO intensive computing and CPU intensive computing
News classification based on LSTM model
MySQL清空表数据
详解JMM
91.(cesium篇)cesium火箭发射模拟
首席信息官对高绩效IT团队定义的探讨和分析