map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}
upstream s3{
   ip_hash;
   server minio:9000 fail_timeout=30s  ;
}
server {
  listen       80 default_server;
  server_name  _;
  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
		client_max_body_size 500m;
    proxy_redirect off;
    proxy_set_header x-scheme $scheme;
    proxy_pass http://drive_full:3000; 
    }
  location /apps{
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
	client_max_body_size 500m;
    proxy_redirect off;
    proxy_set_header x-scheme $scheme;
    proxy_read_timeout    600s;
    location /apps/drive {
      proxy_pass http://drive_full:3000/apps/drive;
      }
    location /apps/editor {
      proxy_pass http://editor_app:5500/apps/editor;
      }
   	location /apps/console {
			proxy_pass http://drive_full:3000/apps/console;
		  }
		location /apps/api {
      proxy_pass http://drive_full:3000/apps/api;
      }
		}
  location /officesite/static{
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    client_max_body_size 500m;
    proxy_redirect off;
    proxy_set_header x-scheme $scheme;
    location /officesite/static/drive {
      proxy_pass http://drive_full:3000/officesite/static/drive;
    }
    location /officesite/static/console {
      proxy_pass http://drive_full:3000/officesite/static/console;
    }
    location /officesite/static/office {
      proxy_pass http://editor_app:5500/officesite/static/office;
    }
    location /officesite/static/editor {
      proxy_pass http://editor_app:5500/officesite/static/editor;
    }
  }
  location  /officesite/resource/custom/favicon.ico{
    proxy_pass http://editor_app:5500/officesite/resource/custom/favicon.ico;
  }
  location /ws{
    proxy_buffering on;
    proxy_buffer_size 4k;
    proxy_buffers 8 1m;
    proxy_busy_buffers_size 2m;
    proxy_max_temp_file_size 1024m;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    location /ws/drive {
      proxy_pass http://drive_full:3000/ws/drive;
    }
    location /ws/admin {
      proxy_pass http://drive_full:3000/ws/drive;
    }
    location /ws/editor {
      proxy_pass http://editor_app:5500/ws/editor;
    }
  }
  location /serviceworker.js {
    proxy_pass http://editor_app:5500/serviceworker.js;
  }
  location /worker.js {
    proxy_pass http://editor_app:5500/worker.js;
  }
	location /s3/{
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-NginX-Proxy true;
    proxy_redirect off;
    proxy_set_header x-scheme $scheme;
    proxy_pass http://minio:9000/;
	}
}
