#
# The default server
#

upstream watchapm_server {
#    hash $remote_addr consistent;
    server 192.168.0.244:8180 fail_timeout=2m;
#    server 192.168.0.244:8280 fail_timeout=2m;
}


upstream nexus_server {
    hash $remote_addr consistent;
    server 192.168.10.153:8081 fail_timeout=2m;
    server 192.168.10.153:8091 fail_timeout=2m;
}


server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Permitted-Cross-Domain-Policies all;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";

        proxy_next_upstream     timeout error;
        proxy_connect_timeout   60;
        proxy_read_timeout      600;
        proxy_buffers           8 64k;
        proxy_buffer_size       8k;
        proxy_busy_buffers_size 64k;


    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location /download {
        autoindex on;
        alias /data2/download2;
    }

    location /nexus {
        # WAS 로드 밸런싱 할 서버군(=upstream server) 지정
        proxy_pass http://nexus_server;
    }



    location / {
#        # WAS 로드 밸런싱 할 서버군(=upstream server) 지정
        proxy_pass http://watchapm_server;
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

