nginx.conf完整配置实例


#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 {

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;

#服务器的集群

upstream  mySite.com { #服务器集群名字

server 192.168.1.101:8080 weight=1;#服务器配置 weight是权重的意思,权重越大,分配的概率越大。

server 192.168.1.102:8080 weight=1;

}

server {

listen 80;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

proxy_pass http://mySite.com;

proxy_redirect default;

}

#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;

# }

#}

}

时间: 2024-08-26 13:58:54

nginx.conf完整配置实例的相关文章

高性能 nginx HTTP服务器 配置实例

分享下nginx http服务器的配置方法. 第一篇:HTTP服务器 因tomcat处理静态资源的速度比较慢,所以首先想到的就是把所有静态资源(JS,CSS,image,swf) 提到单独的服务器,用更加快速的HTTP服务器,这里选择了nginx了,nginx相比apache,更加轻量级, 配置更加简单,而且nginx不仅仅是高性能的HTTP服务器,还是高性能的反向代理服务器. 目前很多大型网站都使用了nginx,新浪.网易.QQ等都使用了nginx,说明nginx的稳定性和性能还是非常不错的.

高性能nginx HTTP服务器 配置实例(转自我的收藏)

分享下nginx http服务器的配置方法. 第一篇:HTTP服务器 因tomcat处理静态资源的速度比较慢,所以首先想到的就是把所有静态资源(JS,CSS,image,swf) 提到单独的服务器,用更加快速的HTTP服务器,这里选择了nginx了,nginx相比apache,更加轻量级, 配置更加简单,而且nginx不仅仅是高性能的HTTP服务器,还是高性能的反向代理服务器. 目前很多大型网站都使用了nginx,新浪.网易.QQ等都使用了nginx,说明nginx的稳定性和性能还是非常不错的.

Nginx虚拟主机配置实例

Nginx虚拟主机 结合上篇文章:手工编译NginxNginx虚拟主机的搭建过程,虚拟主机的概念在之前的Apache虚拟主机搭建实验时已讲述过有关知识点,原文链接:Apache web 虚拟主机 结合上篇文章的配置进行下面的配置操作(Nginx服务是开启状态) [[email protected] named]# netstat -natp | grep 80tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 79214/nginx: master Nginx虚拟主机配置 1

Nginx负载均衡配置实例详解

负载均衡负载均衡是我们大流量网站要做的一个东西,下面我来给大家介绍在Nginx服务器上进行负载均衡配置方法,希望对有需要的同学有所帮助哦.先来简单了解一下什么是负载均衡,单从字面上的意思来理解就可以解释N台服务器平均分担负载,不会因为某台服务器负载高宕机而某台服务器闲置的情况.那么负载均衡的前提就是要有多台服务器才能实现,也就是两台以上即可. 负载均衡的类别轮询            -应用程序轮流来响应请求(nginx默认采用)最少连接    -请求被分配到活动连接最少的服务器上ip-hash

Nginx配置文件(nginx.conf)配置详解

Nginx的配置文件nginx.conf配置详解如下: user nginx nginx ; Nginx用户及组:用户 组.window下不指定 worker_processes 8; 工作进程:数目.根据硬件调整,通常等于CPU数量或者2倍于CPU. error_log  logs/error.log; error_log  logs/error.log  notice; error_log  logs/error.log  info; 错误日志:存放路径. pid logs/nginx.pi

Nginx负载均衡配置实例详解(转)

负载均衡是我们大流量网站要做的一个东西,下面我来给大家介绍在Nginx服务器上进行负载均衡配置方法,希望对有需要的同学有所帮助哦. 负载均衡 先来简单了解一下什么是负载均衡,单从字面上的意思来理解就可以解释N台服务器平均分担负载,不会因为某台服务器负载高宕机而某台服务器闲置的情况.那么负载均衡的前提就是要有多台服务器才能实现,也就是两台以上即可. 测试环境由于没有服务器,所以本次测试直接host指定域名,然后在VMware里安装了三台CentOS. 测试域名  :a.com A服务器IP :19

Nginx负载均衡配置实例

Nginx的负载均衡配置实例. 关于负载均衡的配置实例如下: http{    upstream server {      server 192.168.10.100:80 weight=3 max_fails=3 fail_timeout=25s;      server 192.168.10.101:80 weight=1 max_fails=3 fail_timeout=25s;      server 192.168.10.102:80 weight=4 max_fails=3 fai

nginx.conf中配置laravel框架站点

nginx.conf配置如下: user nginx nginx;worker_processes 4; error_log logs/error.log error; pid logs/nginx.pid;worker_rlimit_nofile 102400; events { use epoll; worker_connections 1024;} http { include mime.types; default_type application/octet-stream; log_f

Nginx 1.10.1 版本nginx.conf优化配置及详细注释

Nginx 1.10.1 的nginx.conf文件,是调优后的,可以拿来用,有一些设置无效,我备注上了,不知道是不是版本的问题,回头查一下再更正. #普通配置 #==性能配置#!异常配置 #运行用户 user nobody; #pid文件 pid logs/nginx.pid; #==worker进程数,通常设置等同于CPU数量,auto为自动检测 worker_processes auto; #==worker进程打开最大文件数,可CPU*10000设置 worker_rlimit_nofi