当前位置:网站首页>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;
}
}
}
边栏推荐
猜你喜欢

Go - exe corresponding to related dependency

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

EasyExcel 复杂数据导出

Redis配置与优化

从零开始学 MySQL —数据库和数据表操作

Pytest Collection (2) - mode de fonctionnement pytest

Mask wearing detection method based on yolov5

mysql 学习笔记-优化之SQL优化

【juc学习之路第9天】屏障衍生工具

List announced | outstanding intellectual property service team in China in 2021
随机推荐
100年仅6款产品获批,疫苗竞争背后的“佐剂”江湖
php反射型xss,反射型XSS测试及修复
require与import的区别和使用
vscode的使用
#yyds干货盘点# 解决名企真题:扭蛋机
MySQL series transaction log redo log learning notes
An operation tool used by we media professionals who earn 1w+ a month
QT 使用FFmpeg4将argb的Qimage转换成YUV422P
Significance and measures of security encryption of industrial control equipment
Introduction and download of the latest version of airserver2022
辅音和声母的区别?(声母与辅音的区别)
Unity 使用Sqlite
详解LockSupport的使用
Airserver mobile phone third-party screen projection computer software
In the past 100 years, only 6 products have been approved, which is the "adjuvant" behind the vaccine competition
91.(cesium篇)cesium火箭发射模拟
Spark interview questions
Sonic云真机学习总结6 - 1.4.1服务端、agent端部署
PHP reflective XSS, reflective XSS test and repair
Manually implement function isinstanceof (child, parent)