当前位置:网站首页>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;
}
}
}
边栏推荐
- Getting started with the lockust series
- Matlab traverses images, string arrays and other basic operations
- 辅音和声母的区别?(声母与辅音的区别)
- mysql 学习笔记-优化之SQL优化
- PCB plug hole technology~
- 名单揭晓 | 2021年度中国杰出知识产权服务团队
- 灵动微 MM32 多路ADC-DMA配置
- The difference between NiO and traditional IO
- 【直播回顾】战码先锋首期8节直播完美落幕,下期敬请期待!
- Wechat applet, continuously playing multiple videos. Synthesize the appearance of a video and customize the video progress bar
猜你喜欢

Getting started with the lockust series

MySQL learning notes - SQL optimization of optimization

Training on the device with MIT | 256Kb memory

Spark interview questions

多种智能指针

pytest合集(2)— pytest运行方式

完全注解的ssm框架搭建

对象内存布局

Manually implement function isinstanceof (child, parent)

Classify boost libraries by function
随机推荐
String type conversion BigDecimal, date type
辅音和声母的区别?(声母与辅音的区别)
burpsuite简单抓包教程[通俗易懂]
MIT|256KB 内存下的设备上训练
What is the difference between consonants and Initials? (difference between initials and consonants)
游览器打开摄像头案例
vscode的使用
js如何获取集合对象中某元素列表
pytest合集(2)— pytest运行方式
linux下清理系统缓存并释放内存
详解LockSupport的使用
AirServer2022最新版功能介绍及下载
基于K-means的用户画像聚类模型
月入1W+的自媒体达人都会用到的运营工具
MQ学习笔记
locust 系列入门
Internet of things RFID, etc
[monomer] recommended configuration of streaming information i-bpsv3 server
An operation tool used by we media professionals who earn 1w+ a month
【深度学习】利用深度学习监控女朋友的微信聊天?