nginx_proxy多虚拟主机解决方案
2015-10-22 19:00
706 查看
背景
![](http://s3.51cto.com/wyfs02/M00/74/C9/wKiom1Yov2iDkvL1AADTsx_ridM174.jpg)
要求
不考虑session会话保持
通过域名来访问不同的虚拟主机。
nginx_proxy配置
本文出自 “挨刀客” 博客,请务必保留此出处http://chboy.blog.51cto.com/9959876/1705346
![](http://s3.51cto.com/wyfs02/M00/74/C9/wKiom1Yov2iDkvL1AADTsx_ridM174.jpg)
要求
不考虑session会话保持
通过域名来访问不同的虚拟主机。
nginx_proxy配置
[root@mysql conf]# cat nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream backend { server 192.168.1.198:80 max_fails=3 fail_timeout=30s; server 192.168.1.197:80 max_fails=3 fail_timeout=30s; } server { listen 80; server_name www.chborg.com; location / { proxy_pass http://backend; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name bbs.chborg.com; location / { proxy_pass http://backend; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name blog.chborg.com; location / { proxy_pass http://backend; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }web服务配置
[root@lnmpconf]# cat nginx.conf worker_processes 1; error_log logs/error.log error; events{ worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; 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; include extra/www.conf; include extra/bbs.conf; include extra/blog.conf; }注解:此处省略extra内的server标签配置
本文出自 “挨刀客” 博客,请务必保留此出处http://chboy.blog.51cto.com/9959876/1705346
相关文章推荐
- Linux Ubuntu Nginx负载均衡 安装 配置
- nginx502错误
- supervisor 使用及管理nginx+gunicorn
- Nginx开启Gzip压缩大幅提高页面加载速度(转)
- nginx简易安装
- nginx的功能个人认识
- nginx优化
- nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
- nginx是以多进程的方式来工作的
- 运行和控制Nginx
- nginx伪静态
- nginx负载均衡+keeplived
- nginx负载均衡之upstream
- Window+nginx+php+mysql安装
- nginx安装
- Nginx基础入门之nginx部署前准备工作
- nginx.conf简单配置
- centos6.7x86_64nginx安装笔记 new
- 安装nginx
- Nginx与真实IP