nginx 实践配置
nginx.conf文件
user root;
worker_processes 1; error_log logs/error.log crit;
#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;
include ccproxy.conf;
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; server_names_hash_bucket_size 256;
client_body_buffer_size 128k;
client_header_buffer_size 8k;
client_max_body_size 50m;
client_header_timeout 1m;
client_body_timeout 1m;
large_client_header_buffers 4 8k; send_timeout 3m; sendfile on;
tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 120;
tcp_nodelay on; gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on; upstream cctest1.com {
server 127.0.0.1:8080 weight=5;
server 127.0.0.1:9080 weight=5;
} server {
listen 80;
server_name ccserver1; #charset koi8-r; access_log logs/host.access.log main; index index.html index.htm index.jsp;
root /usr/common/apache-tomcat-7.0.78_1/webapps/ROOT/; location ~* ^/arch1/.*\.(jpg|jpeg|gif|png|swf|ico)$ {
root /usr/common/apache-tomcat-7.0.78_1/webapps;
} location ~* ^/arch1/.*\.(html|htm|js|css)$ {
root /usr/common/apache-tomcat-7.0.78_1/webapps;
} location ~* .*\.(jpg|jpeg|gif|png|swf|ico)$ {
if (-f $request_filename) {
#expires 15d;
break;
}
} location ~* .*\.(html|htm|js|css)$ {
if (-f $request_filename) {
#expires 1d;
}
} location / {
proxy_pass http://cctest1.com; } #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 {
internal;
root errors/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;
# }
#} }
mime.types文件
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg svgz;
image/webp webp;
application/font-woff woff;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.ms-excel xls;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}
ccproxy.conf文件
#!proxy.conf
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; #获取真实ip
proxy_set_header X-Forward-For $Proxy_add_x_forwarded_for;#获取代理者的真实IP
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 64k;
动态代理 请求header

nginx 实践配置的更多相关文章
- 《深入理解Nginx》阅读与实践(一):Nginx安装配置与HelloWorld
最近在读陶辉的<深入理解Nginx:模块开发与架构解析>,一是想跟着大牛练练阅读和编写开源代码的能力,二是想学学Nginx优秀的架构设计,三是想找一个点深入下Linux下网络编程的细节.侯 ...
- 学习nginx从入门到实践(四) 基础知识之nginx基本配置语法
nginx基本配置语法 1.http相关 展示每次请求的请求头: curl -v http://www.baidu.com 2.nginx日志类型 error.log. access.log log_ ...
- nginx服务配置---php服务接入
前言: 最近要搭建一个内部的wiki系统, 网上搜了一圈, 也从知乎上搜集了一些大神的评价和推荐. 重点找了几个开源的wiki系统, 不过发现他们都是采用php来实现的. 于是乎需要配置php环境, ...
- Nginx安装配置与HelloWorld
<深入理解Nginx>阅读与实践(一):Nginx安装配置与HelloWorld 最近在读陶辉的<深入理解Nginx:模块开发与架构解析>,一是想跟着大牛练练阅读和编写开源代码 ...
- linux环境手动编译安装Nginx实践过程 附异常解决
1.下载nginx源码包并解压 可在http://nginx.org/en/download.html下载.tar.gz的源码包,如(nginx-1.4.7.tar.gz) 或者使用云盘下载 ht ...
- 大规模网站sesson会话保持思路及实践配置
1.需求: 请教个问题:我用lvs的rr模式,(考虑过 ipvsadm -p,但是这样就失去了负载均衡的意义感觉),后端有10台web,用一台memcached专门用于存储session文件,但是现在 ...
- nginx syslog 配置
以下是一个简单的实践,主要是打算测试nginx 与graylog 的集成,为了简单都是使用容器运行的,同时也测试了 nginx 对于配置多个access_log 的处理 环境准备 docker-com ...
- 如何在Nginx下配置PHP程序环境
1.nginx与PHP的关系 首先来看nginx与php的关系, FastCGI的关系(而不是像apache那样安装成nginx的模块) FastCGI的意思是, 快速的通用网关接口:CGI Comm ...
- 从零开始学 Java - CentOS 下 Nginx + Tomcat 配置负载均衡
为什么现在有非常多的聪明人都在致力于互联网? 最近在读埃隆·马斯克传记,他说「我认为现在有非常多的聪明人都在致力于互联网」. 仔细一想,好像真的是这样的. 我问了自己一个问题:如果你不敲代码了,你能做 ...
随机推荐
- 两大主流开源分布式存储的对比:GlusterFS vs. Ceph
两大主流开源分布式存储的对比:GlusterFS vs. Ceph 存储世界最近发生了很大变化.十年前,光纤通道SAN管理器是企业存储的绝对标准,但现在的存储必须足够敏捷,才能适应在新的基础架构即服务 ...
- 手写alert弹框(一)
采用原生的JavaScript, html代码 <meta name="viewport" content="width=device-width, initial ...
- django中安装pillow ValueError: zlib is required unless explicitly disabled using --disable-zlib, aborting
在windows系统上,使用 pip install pillow安装pillow时 报错 在使用 easy_install Pillow 方式安装成功,默认是最高版本 如果需要在安装时,指定安装版 ...
- Flutter安装
下载右边的安装包以获取最新版本 stable 的 Flutter SDK 将压缩包解压,然后把其中的 flutter 目录整个放在你预想的 Flutter SDK 安装目录中(比如 C:\src\fl ...
- mysql—并发控制及事务
并发控制 实现的并发访问的控制技术是基于锁: 锁分为表级锁和行级锁,MyISAM存储引擎不支持行级锁:InnoDB支持表级锁和行级锁: 锁的分类有读锁和写锁,读锁也被称为共享锁,加读锁的时候其他的人可 ...
- 响应式css样式
<div class="a"> 123 </div> @media(orientation:portrait) and (max-width:600px){ ...
- python —— 生成器
通过列表生成式,我们可以直接创建一个列表.但是,受到内存限制,列表容量肯定是有限的.而且,创建一个包含100万个元素的列表,不仅占用很大的存储空间,如果我们仅仅需要访问前面几个元素,那后面绝大多数元素 ...
- 分组背包---P1757 通天之分组背包
P1757 通天之分组背包 题解 分组背包板子题 k组物品,每组之间相互矛盾,也就是一组里面只能选一个或者不选 分组背包其实和01背包差不多,就是多加一维枚举组数 f[k][j] 前k组中,体积不超过 ...
- Qt编写自定义控件20-自定义饼图
前言 上次在写可视化数据大屏电子看板项目的时候,为了逐步移除对QChart的依赖(主要是因为QChart真的太垃圾了,是所有Qt的模块中源码最烂的一个,看过源码的人没有一个不吐槽,不仅不支持10W级别 ...
- 如果使用 Python3(Flask) 一步一步模拟一个网页微信客户端
目录 Web Weixin Pipeline 一.获取登录的二维码 1.1.打开浏览器输入下面网址 1.2.梳理原理 1.3.代码实现 1.4.启动测试 二.扫码成功 2.1.扫码状态 2.2.原理状 ...