nginx配置笔记
2016-07-05 14:50
585 查看
#user nginx nginx; #无用户注释掉
worker_processes 4;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
default_type application/octet-stream;
charset utf-8;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_buffer_size 32k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
# proxy_temp_file_write_size 1024m;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zone crawler $binary_remote_addr 10m;
include vhost/*.conf;
#include deny_ip.conf;
}
vhost/authsys.conf
log_format authsys '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
server
{
listen 1181;
server_name 192.168.168.112:8080; #若为域名指向域名
if ($request_uri ~ ".*/.svn/.*")
{
return 404;
}
location / {
proxy_pass http://192.168.168.112:8080/;#若为域名指向域名
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log /usr/local/nginx/logs/authsys.log authsys;
}
}
如需负载均衡配置如下 :vhost/upstream.conf
ip指向,解决session共享问题
upstream xxcom
{
ip_hash;
server 192.168.0.12:80 max_fails=2 fail_timeout=5s;
}
worker_processes 4;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
default_type application/octet-stream;
charset utf-8;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_buffer_size 32k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
# proxy_temp_file_write_size 1024m;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zone crawler $binary_remote_addr 10m;
include vhost/*.conf;
#include deny_ip.conf;
}
vhost/authsys.conf
log_format authsys '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
server
{
listen 1181;
server_name 192.168.168.112:8080; #若为域名指向域名
if ($request_uri ~ ".*/.svn/.*")
{
return 404;
}
location / {
proxy_pass http://192.168.168.112:8080/;#若为域名指向域名
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log /usr/local/nginx/logs/authsys.log authsys;
}
}
如需负载均衡配置如下 :vhost/upstream.conf
ip指向,解决session共享问题
upstream xxcom
{
ip_hash;
server 192.168.0.12:80 max_fails=2 fail_timeout=5s;
}
相关文章推荐
- Nginx整合mp4,flv模块
- Web服务图片压缩,nginx+lua生成缩略图
- Linux下,Nginx的安装、升级及动态添加模块
- 在centos里安装Nginx
- 使用Nginx+Lua(OpenResty)开发高性能Web应用
- 使用saltstack编译安装nginx
- nginx+uwsgi python应用
- nginx在linux安装笔记
- nginx配置时的一些问题
- nginx代理服务器
- Ubuntu上安装Nginx服务器程序及简单的环境配置小结
- Flask采用Virtualenv+Supervisor+Nginx部署应用
- Asp.Net Core 发布和部署( MacOS + Linux + Nginx )
- NGINX_ERR_INCOMPLETE_CHUNKED_ENCODING
- nginx下支持PATH_INFO详解
- [省了index.php看这] Nginx下支持ThinkPHP的Pathinfo和URl Rewrite模式
- Nginx安装与简单的负载均衡(centos6.5)
- 你用的Nginx还很低性能么,来看看此篇文章!
- nginx作为下载文件服务器
- 增强 nginx 的 SSL 安全性