#!/bin/bash
# configure local yum repo
cat > /etc/yum.repos.d/yum_local.repo << EOF
[yum_local]
name=yum_local
baseurl=http://192.168.1.61
gpgcheck=0
enabled=1
EOF
yum clean all
yum makecache
# install nginx
yum install nginx -y
# configure nginx
mv /etc/nginx/nginx.conf{,.backup}
cat > /etc/nginx/nginx.conf << EOF
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream static_pools {
server 192.168.1.17:80 weight=1;
}
upstream upload_pools {
server 192.168.1.18:80 weight=1;
}
upstream default_pools {
server 192.168.1.19:80 weight=1;
}
server {
listen 80;
server_name www.will.com;
location / {
proxy_pass http://default_pools;
include proxy.conf;
}
location /static/ {
proxy_pass http://static_pools;
include proxy.conf;
}
location /upload/ {
proxy_pass http://upload_pools;
include proxy.conf;
}
}
}
EOF
cat > /etc/nginx/proxy.conf << EOF
proxy_set_header Host \$host;
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
EOF
# start nginx
systemctl start nginx
systemctl enable nginx