背景
要求
不考虑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标签配置