官方介紹:
“Nginx是一款輕量級的HTTP服務器,采用事件驅動的異步非阻塞處理方式框架,這讓其具有極好的IO性能,時常用于服務端的反向代理和負載均衡,”
Nginx的優點
- 支持海量高并發:采用IO多路復用epoll,官方測驗Nginx能夠支持5萬并發鏈接,實際生產環境中可以支撐2-4萬并發連接數,
- 記憶體消耗少:在主流的服務器中Nginx目前是記憶體消耗最小的了,比如我們用Nginx+PHP,在3萬并發鏈接下,開啟10個Nginx行程消耗150M記憶體,
- 免費使用可以商業化:Nginx為開源軟體,采用的是2-clause BSD-like協議,可以免費使用,并且可以用于商業,
- 組態檔簡單:網路和程式配置通俗易懂,即使非專業運維也能看懂,
現在Nginx非常火 :我們可以通過https://w3techs.com/ 這個網站看到,Nginx在服務器中排在第二位,但是是上升最快的網站,占有率達到39.7%,
組態檔
#user nobody;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 81;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root D:\project2\data-center-ui\dist;
index index.html index.htm;
}
location ^~ /backend/ {
proxy_pass http://192.168.1.2:8082/admin/; #后端系統連接地址,即前面步驟配置的應用訪問地址,如果在weblogic中為應用配置了應用背景關系,則在這里也要加上
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/312084.html
標籤:其他
上一篇:HUAWEI永遠滴神!華為頂級網路專家總結出了這份網路協議開源手冊
下一篇:測驗nginx組態檔正確性
