当前位置:网站首页>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;
}
}
}
边栏推荐
- In the past 100 years, only 6 products have been approved, which is the "adjuvant" behind the vaccine competition
- 多种智能指针
- 旁路由设置的正确方式
- 从MLPerf谈起:如何引领AI加速器的下一波浪潮
- 为什么数字化转型战略必须包括持续测试?
- Talking from mlperf: how to lead the next wave of AI accelerator
- 完全注解的ssm框架搭建
- [NOIP2013]积木大赛 [NOIP2018]道路铺设 贪心/差分
- 【MySQL】索引的创建、查看和删除
- Go - exe corresponding to related dependency
猜你喜欢
随机推荐
pytest合集(2)— pytest運行方式
Unity uses SQLite
中通笔试题:翻转字符串,例如abcd打印出dcba
locust 系列入门
List announced | outstanding intellectual property service team in China in 2021
News classification based on LSTM model
Classify boost libraries by function
Little p weekly Vol.11
MySQL系列之事务日志Redo log学习笔记
详解LockSupport的使用
微信小程序,连续播放多段视频。合成一个视频的样子,自定义视频进度条
【MySQL】索引的创建、查看和删除
统计字符中每个字符出现的个数
详解ThreadLocal
测试撤销1
Wechat applet, continuously playing multiple videos. Synthesize the appearance of a video and customize the video progress bar
91.(cesium篇)cesium火箭发射模拟
IDA动态调试apk
【生态伙伴】鲲鹏系统工程师培训
require与import的区别和使用








