想了解nginx的代理能夠先看這篇:php
https://baijiahao.baiducom/s?id=1652608869911988442&wfr=spider&for=pchtml
nginx -t ##檢查配置文件,通常修改完配置文件都建議必定先執行這條命令檢查一下,無誤再繼續下一步
nginx –s reload ##從新加載配置文件,動態加載使你能夠不用重啓nginxnginxnginx -s reopen # 重啓 Nginxnginx -s stop # 中止 Nginx
咱們能夠打開nginx的配置文件 nginx.conf 先看看session
#user nobody; #Nginx用戶及組:用戶 組。window下不指定 worker_processes 1; #工做進程:數目。根據硬件調整,一般等於CPU數量或者2倍於CPU。 #錯誤日誌:存放路徑。 #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 8088; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #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; # } #} }
events模塊配置:events事件指令是設定Nginx的工做模式及鏈接數上限。每一個配置選項的含義解釋以下:
a、use
如:use epoll;
use是事件模塊指令,用來指定Nginx的工做模式。Nginx支持的工做模式有select、poll、kqueue、epoll、rtsig和/dev/poll 。其中select 和poll 都是標準的工做模式,kqueue和epoll是高效的工做模式,不一樣的是epoll用在Linux平臺上,而kqueue用在BSD系統中。對於Linux系統,epoll工做模式是首選。
b、worker_connections
如:worker_connections65536;
work_connections也是個事件模塊指令,用於定義Nginx每一個進程的最大鏈接數,默認是1024。