#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
use epoll;
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;
gzip_types text/plain application/xml text/xml text/css text/javascript application/json application/x-javascript application/x-shockwave-flash;
gzip_vary on;
gzip_comp_level 2;
upstream app_server {
server 192.168.1.101:7780 weight=1;
server 192.168.1.102:7780 weight=1;
}
server {
listen 80;
server_name 192.168.1.101;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm index.jsp;
proxy_pass http://app_server;
proxy_set_header X-Real-IP $remote_addr;
}
#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;
#}
location ~ ^/(WEB-INF)/ {
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;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
${nginx_home}/sbin/nginx -? 可以查看nginx各种命令参数
常用的有
1) 测试配置文件是否正确
${nginx_home}/nginx -t -c ${nginx_home}/conf/nginx.conf
2) 重启nginx
${nginx_home}/nginx -s reolad
分享到:
相关推荐
主要介绍了nginx负载均衡配置,宕机自动切换方式,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
nginx负载均衡配置文件实例:基本配置说明文档和一个配置好的nginx.conf文件实例
Nginx和tomcat配置负载均衡集群,互相学习哈,给大家参考,有问题可以做修改
nginx负载均衡配置-windows.docx
Tomcat在高并发环境下处理动态请求时性能很低,而在处理静态页面更加脆弱。是通过Nginx来处理静态页面要比通过Tomcat处理在性能方面好很多。本例为nginx负载均衡配置方法
NGINX负载均衡配置。步骤很详细,亲测可用,大家可以试试
Nginx负载均衡配置.pdf
redis+tomcat+nginx负载均衡配置 非常详细,下载放入项目即可使用
tomcat7.0.5+nginx负载均衡配置,里面有例子可以直接运行看到效果哦。
nginx进行负载均衡的配置参考示例,及nginx支持https请求的配置参考示例
nginx 负载均衡与缓存服务器标准配置文件
nginx配置 +负载均衡+https协议 完整的配置以及nginx 启动 停止 重新加载
Nginx负载均衡资料,Nginx负载均衡配置文档
Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型的网页服务器中表现较好,中国大陆使用...
Nginx负载均衡搭建及配置技术,尽可能详细介绍了相关配置用法及静态资源配置相关,提高服务器运行及运维方面的知识