Nginx实现动静分离
来源:互联网 发布:淘宝上签证怎么办理 编辑:程序博客网 时间:2024/05/01 22:54
nginx可实现负载均衡,并在此基础上实现动静分离。
负载均衡配置。在http模块中做如下配置:
upstream website1{ server 192.168.0.100 weight=2; server 192.168.0.200 weight=3; server 192.168.0.222 weigth=4;}
其中,weight是权重值,权重越大,命中率越高。
下面再配置server模块:
server{ listen 80; server_name www.penkr.com; index index.php index.html index.htm; root /data/www/www.penkr.com; location / { proxy_next_upstream http_502 http_504 error timeout invalid_header; 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_pass http://website1; } location ~ .*\.(php|jsp|cgi|shtml) { 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_pass http://website1; } location ~ *.\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css) { root /data/www/www.penkr.com; }}
第二个location 表示所有的动态请求都请求到负载服务器
第三个location 表示所有的静态请求都请求本地资源
这就实现了动静分离。
0 0
- Nginx实现动静分离
- Nginx动静分离实现
- Nginx动静分离实现
- Nginx动静分离实现
- Nginx动静分离实现
- nginx+tomcat实现动静分离
- Nginx+Tomcat实现动静分离
- Nginx+Tomcat实现动静分离
- apache+nginx 实现动静分离
- nginx+tomcat实现动静分离
- Nginx + Tomcat 实现动静分离
- Nginx + Tomcat 实现动静分离
- Nginx + Tomcat 实现动静分离
- apache+nginx 实现动静分离
- Nginx+Tomcat实现动静分离
- Nginx实现简单动静分离
- Nginx + Tomcat 实现动静分离
- Nginx+Tomcat实现动静分离
- Unicode与JavaScript详解
- 架构之路:nginx与IIS服务器搭建集群实现负载均衡(二)
- bmob 后台云服务使用
- ios Masonry布局
- 我的python笔记
- Nginx实现动静分离
- react-native源码系列三 native c++代码到js代码
- 并查集uva1160 - X-Plosives
- NAO机器人之开发环境搭建
- 用视图控件 实现简单的跑马灯
- 如何创建html文件
- C/C++编译和链接过程详解 (重定向表,导出符号表,未解决符号表)
- 数据结构与算法——字典序最小问题(用string类实现)
- Leetcode: Range Sum Query - Mutable