Nginxでリバースプロキシ

仕事でNginxでリバースプロキシを作ったのでメモ。
まだ、細かい調整はしてない。
インストールは以下と同じ手順でnginx.confも基本的に同じ。
Nginxインストール - i2bsの日記

nginx.conf修正

vi /usr/local/nginx/conf/nginx.conf
http {
    ...
    ...
    include proxy.conf;
}

proxy.conf作成

vi /usr/local/nginx/conf/proxy.conf
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 15;
proxy_send_timeout 15;
proxy_read_timeout 15;

vhosts_proxy.conf

vi /usr/local/nginx/conf/conf.d/xxx.com.conf
upstream xxx {
    #ip_hash
    server xxx.com:xxx weight=1 max_fails=5 fail_timeout=60s;
    server xxx.com:xxx weight=1 max_fails=5 fail_timeout=60s;
    server xxx.com:xxx weight=1 max_fails=5 fail_timeout=60s;
    server sorry.xxx.com:xxx backup;
}

server {
    listen 80;
    server_name xxx.com;
    root vhosts/xxx.com/htdocs;

    access_log vhosts/xxx.com/logs/access.log main;
    error_log vhosts/xxx.com/logs/error.log info;

    #auth_basic "xxx";
    #auth_basic_user_file vhosts/xxx.com/etc/.htpasswd;

    location / {
        proxy_pass http://xxx;
    }
}

server {
    listen 443 ssl;
    server_name xxx.com;
    root vhosts/xxx.com/htdocs;

    access_log vhosts/xxx.com/logs/ssl_access.log main;
    error_log vhosts/xxx.com/logs/error.log notice;

    ssl on;
    ssl_certificate vhosts/xxx.com/ssl.crt/server.crt;
    ssl_certificate_key vhosts/xxx.com/ssl.key/server.key;

    ssl_session_timeout 5m;

    ssl_protocols SSLv2 SSLv3 TLSv1;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    #auth_basic "xxx";
    #auth_basic_user_file vhosts/xxx.com/etc/.htpasswd;

    location / {
        proxy_pass http://xxx;
    }
}