Nginx基礎知識
nginx學習筆記
安裝
yum方式安裝openssl、pcre、zlib
yum -y install openssl openssl-devel
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
下載安裝Nginx(安裝目錄在/usr/local/nginx,安裝ssl模組)
wget http://nginx.org/download/nginx-1.15.0.tar.gz
tar -zxvf nginx-1.15.0.tar.gz
cd nginx-1.15.0
./configure --sbin-path=/usr/local/nginx/nginx --with-http_ssl_module
make && make install
啟動
檢視nginx的pid
cd usr/local/nginx/logs
cat nginx.pid
1、檢視 nginx版本號
./nginx -v
2、啟動 nginx
./nginx
3、停止 nginx
./nginx -s stop
4、重新載入
./nginx -s reload
轉發
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 9000;
server_name 100.100.100.4;
location ~ /edu/ {
proxy_pass http://100.100.100.4:8081;
}
location ~ /vod/ {
proxy_pass http://100.100.100.4:8082;
}
}
}
負載均衡
nginx 負載均衡
1.輪詢
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream xiaoquserver{
server 100.100.100.4:8081;
server 100.100.100.4:8082;
}
server {
listen 9000;
server_name 100.100.100.4;
location / {
root html;
proxy_pass http://xiaoquserver;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
2.權重
upstream xiaoquserver{
server 100.100.100.4:8081 weight=1;
server 100.100.100.4:8082 weight=2;
}
3.ip hash
upstream xiaoquserver{
ip_hash;
server 100.100.100.4:8081 weight=1;
server 100.100.100.4:8082 weight=2;
}
4. 最少連線 分配到最少連線上
upstream xiaoquserver{
least_conn;
server 100.100.100.4:8081 weight=1;
server 100.100.100.4:8082 weight=2;
}
5.後端伺服器的響應時間來分配請求,響應時間短的優先分配
upstream xiaoquserver{
server 100.100.100.4:8081 weight=1;
server 100.100.100.4:8082 weight=2;
fair;
}
相關文章
- SSL基礎知識及Nginx/Tomcat配置SSLNginxTomcat
- 滲透測試基礎知識---nginx安全配置Nginx
- 基礎知識
- AI 基礎知識AI
- Webpack 基礎知識Web
- Dart基礎知識Dart
- RabbitMQ基礎知識MQ
- webpack基礎知識Web
- javascript基礎知識JavaScript
- ThinkPHP基礎知識PHP
- Laravel基礎知識Laravel
- Redis基礎知識Redis
- Docker基礎知識Docker
- 程式基礎知識
- Envoy基礎知識
- DockerFile基礎知識Docker
- CSS基礎知識CSS
- Java基礎知識Java
- PRML 基礎知識
- BGP基礎知識
- PHP基礎知識PHP
- React基礎知識React
- httpclient基礎知識HTTPclient
- HBase基礎知識
- Jquery基礎知識jQuery
- js基礎知識JS
- PGA基礎知識
- Javascript 基礎知識JavaScript
- ASM基礎知識ASM
- html基礎知識HTML
- 黑客基礎知識黑客
- Mysqli基礎知識MySql
- oracle 基礎知識Oracle
- SEO基礎知識
- CMMI 基礎知識
- Kafka 基礎知識Kafka
- 1、基礎知識
- qml基礎知識