nginx的一些简单配置
2017-07-18 14:55
176 查看
mac下修改/usr/local/nginx/conf/nginx.conf配置文件
反向代理加负载均衡:
反向代理加负载均衡:
user nobody; worker_processes auto;#nginx 进程数,建议按照cpu 数目来指定,一般为它的倍数,auto是自动检测 #一个nginx 进程打开的最多文件描述符数目,理论值应该是最多打开文件数(ulimit -n)与nginx 进程数相除, #但是nginx 分配请求并不是那么均匀,所以最好与ulimit -n 的值保持一致, #这个是系统打开文件限制有关,如果系统没有更改这里设置再高也没有用,会报24: Too many open files的错误, #mac压力测试前先ulimit -n 10000,10000据说是mac的上限,linux上限是60000,但是也有人说8g的mac上限只有2500, #经过我的测试即使ulimit -n 10000设置了,worker_rlimit_nofile设置为10000和2048的效果没什么区别 worker_rlimit_nofile 2048; error_log logs/error.log;#错误日志 #error_log logs/error.log notice; #error_log logs/error.log info; pid logs/nginx.pid;#进程号 events { worker_connections 2048;#每个进程允许的最多连接数, 理论上每台nginx 服务器的最大连接数为worker_processes*worker_connections multi_accept on; #use epoll;#使用epoll的I/O模型,linux2.6以上才能用,mac,windows都不能用 } 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;#打开压缩 upstream backend { #ip_hash; # 负载均衡,backend是组名 server 127.0.0.1:5000; server 127.0.0.1:5001; server 127.0.0.1:5002; server 127.0.0.1:5003; } server { listen 8089;#端口 server_name localhost;#ip #charset koi8-r; #access_log logs/host.access.log main; #location / { #root html; #index index.html index.htm; #} location / { try_files @uri @pp; } location @pp { # 方向代理 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass http://backend;#如果用负载均衡使用组名,如果只是反向代理使用要代理的ip和端口如http://127.0.0.1:5000 } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html;#50x的错误页面 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; # } #} }
相关文章推荐
- LNMP及nginx的一些简单配置
- Nginx 简单的负载均衡配置示例
- Nginx简单配置
- Nginx 简单的负载均衡配置示例
- Nginx简单配置(Windows环境)
- nginx的反向代理搭建配置以及搭建过程中的一些思维发散
- ECS centos6.8系统下从nginx安装到简单网站上线配置操作的完整记录
- Nginx配置文件简单说明
- DNS查询与BIND名字服务器的一些简单配置文件说明
- nginx 配置管理 - 简单也复杂
- nginx一些参数配置详解
- nginx的安装及简单负载均衡配置
- 以实际的WebGIS例子探讨Nginx的简单配置
- .babelrc文件的一些简单的配置
- nginx一些参数配置
- Debian下简单配置Nginx + Uwsgi + Flask
- Nginx 简单的负载均衡配置示例
- Nginx简单安装配置(V1.7.8)
- Nginx 简单的负载均衡配置示例[原创]
- linux+nginx+tomcat集群-简单配置文件