LB: nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream www_server_pools { server 192.1.1.9:80 weight=1; server 192.1.1.10:80 weight=1; } upstream bbs_server_pools { server 192.1.1.9:80 weight=1; server 192.1.1.10:80 weight=1; } server { listen 80; server_name www.lufeng.com; location / { proxy_pass http://www_server_pools; include proxy.conf; } } server { listen 80; server_name bbs.lufeng.com; location / { proxy_pass http://bbs_server_pools; include proxy.conf; } } } proxy.conf proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; WEB01 WEB02 worker_processes 1; error_log logs/error.log; 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"‘; include extra/bbs.conf; include extra/blog.conf; include extra/www.conf; } bbs.conf server { listen 80; server_name bbs.lufeng.com; root html/bbs; index index.php index.html index.html; location ~ .*\.(php|php5)?$ { root html/bbs; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } access_log logs/access_bbs.log main; } blog.conf server { listen 80; server_name blog.lufeng.com; root html/blog; index index.php index.html index.html; location / { if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.html){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /index.php; } } location ~ .*\.(php|php5)?$ { root html/blog; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } access_log logs/access_blog.log main; }
时间: 2024-10-12 19:10:22