Skip to content

Commit

Permalink
web负载均衡服务器搭建
Browse files Browse the repository at this point in the history
  • Loading branch information
EleTeam committed Apr 4, 2017
1 parent eb3a1ee commit 95fe3e2
Show file tree
Hide file tree
Showing 5 changed files with 422 additions and 0 deletions.
41 changes: 41 additions & 0 deletions docs/服务器搭建/nginx-proxy_nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
worker_processes 1;

error_log logs/error.log;

pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

sendfile on;

keepalive_timeout 65;

upstream lb {
server 127.0.0.1:8001;
server 127.0.0.1:8002;
}

server {
listen 80;
server_name localhost;

# 响应头中添加请求转向那台服务的ip和状态码
add_header backendIP $upstream_addr;
add_header backendCode $upstream_status;

location / {
#反向代理到自己的upstream, 里面的多个server实现负载均衡
proxy_pass http://lb;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
151 changes: 151 additions & 0 deletions docs/服务器搭建/nginx-web01_nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#user nobody;
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;

#gzip on;

server {
listen 8001;
server_name eleteam.com www.eleteam.com;

location / {
root html/Shop-PHP-Yii2/frontend/web;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}

location ~ /(css|js|f7|image|assets) {
root html/Shop-PHP-Yii2/frontend/web;
}
}

server {
listen 8001;
server_name m.eleteam.com;

location / {
root html/Shop-PHP-Yii2/wap/web;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}

location ~ /(css|js|f7|image|assets) {
root html/Shop-PHP-Yii2/wap/web;
}
}

server {
listen 8001;
server_name admin.eleteam.com;

location / {
root html/Shop-PHP-Yii2/backend/web;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}

location ~ /(css|js|f7|image|adminlte|assets|fonts|huiadmin|upload) {
root html/Shop-PHP-Yii2/backend/web;
}
}

server {
listen 8001;
server_name api.eleteam.com;

location / {
root html/Shop-PHP-Yii2/api/web;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

server {
listen 8001;
server_name data.eleteam.com;

location / {
root html/Shop-PHP-Yii2/data;
}
}

server {
listen 8001;
server_name requirements.eleteam.com;

location / {
root html/Shop-PHP-Yii2;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index requirements.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

# 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;
# }
#}

}
152 changes: 152 additions & 0 deletions docs/服务器搭建/ngnix-web02_nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#user nobody;
#user root;
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;

#gzip on;

server {
listen 8002;
server_name eleteam.com www.eleteam.com;

location / {
root html/Shop-PHP-Yii2/frontend/web;
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}

location ~ /(css|js|f7|image|assets) {
root html/Shop-PHP-Yii2/frontend/web;
}
}

server {
listen 8002;
server_name m.eleteam.com;

location / {
root html/Shop-PHP-Yii2/wap/web;
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}

location ~ /(css|js|f7|image|assets) {
root html/Shop-PHP-Yii2/wap/web;
}
}

server {
listen 8002;
server_name admin.eleteam.com;

location / {
root html/Shop-PHP-Yii2/backend/web;
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}

location ~ /(css|js|f7|image|adminlte|assets|fonts|huiadmin|upload) {
root html/Shop-PHP-Yii2/backend/web;
}
}

server {
listen 8002;
server_name api.eleteam.com;

location / {
root html/Shop-PHP-Yii2/api/web;
fastcgi_pass 127.0.0.1:9002;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

server {
listen 8002;
server_name data.eleteam.com;

location / {
root html/Shop-PHP-Yii2/data;
}
}

server {
listen 8002;
server_name requirements.eleteam.com;

location / {
root html/Shop-PHP-Yii2;
fastcgi_pass 127.0.0.1:9002;
fastcgi_index requirements.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

# 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;
# }
#}

}
Loading

0 comments on commit 95fe3e2

Please sign in to comment.