nginx 1.8.1怎么配置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx 1.8.1怎么配置相关的知识,希望对你有一定的参考价值。
参考技术A 相关配置文件:1、nginx.conf
user www www;
worker_processes 4;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events
use epoll;
worker_connections 1024;
http
upstream tomcat7
server 127.0.0.1:8090;
upstream fdfs
server 192.168.77.32:8888;
pagespeed On;
pagespeed FileCachePath “/var/cache/ngx_pagespeed/”;
pagespeed EnableFilters combine_css,combine_javascript;
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_min_length 1000;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript text/css application/xml;
include vhost.conf;
include vhost/*;
vhost.conf是默认项目,里面是一个虚拟机配置,
server
listen 80;
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;
error_page 500 502 503 504 /50x.html;
location = /50x.html
root html;
下面把一个典型的虚拟机配置:
test.conf
server
listen 80;
server_name test.qq.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 30;
proxy_read_timeout 60;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_max_temp_file_size 128m;
proxy_set_header Host $host;
proxy_pass_header User-Agent;
location /
proxy_pass http://tomcat7;
location /assets
root html;
index index.html;
#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;
Nginx系列
包括nginx的入门和进阶学习。
目录
nginx系列10:通过upstream模块选择上游服务器和负载均衡策略round-robin
nginx系列11:负载均衡哈希算法ip_hash与hash模块
nginx系列13:最少连接算法以及如何跨worker进程生效
参考资料
以上是关于nginx 1.8.1怎么配置的主要内容,如果未能解决你的问题,请参考以下文章