server {
    listen 80;

    add_header 'Access-Control-Allow-Origin' '*' always;
    add_header 'Access-Control-Allow-Headers' '*' always;
    add_header 'Access-Control-Allow-Methods' 'AUTHORIZATION,ACCEPT,GET,POST,OPTIONS,PUT,DELETE' always;

    location /irods-rest/0.9.3/access {
        if ($request_method = 'OPTIONS') {
            return 204;
        }

        proxy_pass http://irods-client-rest-cpp:8080;
    }

    location /irods-rest/0.9.3/admin {
        if ($request_method = 'OPTIONS') {
            return 204;
        }

        proxy_pass http://irods-client-rest-cpp:8087;
    }

    location /irods-rest/0.9.3/auth {
        if ($request_method = 'OPTIONS') {
            return 204;
        }

        proxy_pass http://irods-client-rest-cpp:8081;
    }

    location /irods-rest/0.9.3/get_configuration {
        if ($request_method = 'OPTIONS') {
            return 204;
        }

        proxy_pass http://irods-client-rest-cpp:8088;
    }

    location /irods-rest/0.9.3/put_configuration {
        if ($request_method = 'OPTIONS') {
            return 204;
        }

        proxy_pass http://irods-client-rest-cpp:8089;
    }

    location /irods-rest/0.9.3/list {
        if ($request_method = 'OPTIONS') {
            return 204;
        }

        proxy_pass http://irods-client-rest-cpp:8082;
    }

    location /irods-rest/0.9.3/query {
        if ($request_method = 'OPTIONS') {
            return 204;
        }

        proxy_pass http://irods-client-rest-cpp:8083;
    }

    location /irods-rest/0.9.3/stream {
        if ($request_method = 'OPTIONS') {
            return 204;
        }

        if ($request_method = GET) {
            proxy_pass http://irods-client-rest-cpp:8084;
        }

        if ($request_method = PUT) {
            proxy_pass http://irods-client-rest-cpp:8085;
        }
    }

    location /irods-rest/0.9.3/zonereport {
        if ($request_method = 'OPTIONS') {
            return 204;
        }

        proxy_pass http://irods-client-rest-cpp:8086;
    }

    location /irods-rest/0.9.3/logicalpath {
        if ($request_method = 'OPTIONS') {
            return 204;
        }

        proxy_pass http://irods-client-rest-cpp:8090;
    }

    location /irods-rest/0.9.3/metadata {
        if ($request_method = 'OPTIONS') {
            return 204;
        }

        proxy_pass http://irods-client-rest-cpp:8091;
    }
}
