server {
    listen 80;
    server_name localhost DOMAIN_NAME;
    client_max_body_size 4096m;
    
   rewrite ^(.*)$ https://$host$1 permanent;

}
server {
    listen       443 ssl;
    server_name  localhost DOMAIN_NAME;

    #charset koi8-r;
    #access_log  /var/log/nginx/access.log  main;
    ssl_certificate     SSL_CERT;
    ssl_certificate_key SSL_KEY;
    client_max_body_size 4096m;
	
   if ($cookie_maxspeed) {
       set $limit_rate $cookie_maxspeed;
    }
	
    proxy_send_timeout 300s;
    proxy_read_timeout 300s;
    keepalive_timeout 300s;
	
    proxy_max_temp_file_size 0;
	
    # location =/ {
    # 	proxy_pass http://edoc2_ip/index.html;
	# 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;
	# client_max_body_size 0;
	# proxy_http_version 1.1;
    #     proxy_set_header Connection "";
	# proxy_request_buffering off;
	# #proxy_buffering off;
    #     proxy_next_upstream error timeout http_502 http_504;
    # }

    location / {
    	proxy_pass http://edoc2_ip;
	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;
	client_max_body_size 0;
	proxy_http_version 1.1;
        proxy_set_header Connection "";
	proxy_request_buffering off;
	#proxy_buffering off;
        proxy_next_upstream error timeout http_502 http_504;
    }


    location =/signalr {
        proxy_pass http://edoc2_ip;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header  X-Real-IP $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    }


    location /FileAgent {
        proxy_pass http://transport_ip;
        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;
        client_max_body_size 0;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_request_buffering off;
        #proxy_buffering off;
	proxy_next_upstream error timeout http_502 http_504;
    }

    location /document/uploadMultiTd {
        proxy_pass http://transport_ip;
        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;
        client_max_body_size 0;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_request_buffering off;
        #proxy_buffering off;
    }

    location /document/upload {
        proxy_pass http://transport_ip;
        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;
        client_max_body_size 0;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_request_buffering off;
        #proxy_buffering off;
    }
    location /document/diffupdate {
        proxy_pass http://transport_ip;
        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;
        client_max_body_size 0;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_request_buffering off;
        #proxy_buffering off;
    }
    location /downLoad/index {
        proxy_pass http://transport_ip;
        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;
        client_max_body_size 0;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_request_buffering off;
        #proxy_buffering off;
	proxy_next_upstream error timeout http_502 http_504;
    }
       location /downLoad/Index {
        proxy_pass http://transport_ip;
        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;
        client_max_body_size 0;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_request_buffering off;
        #proxy_buffering off;
	proxy_next_upstream error timeout http_502 http_504;
    }
    location /downLoad/GetFile {
        proxy_pass http://transport_ip;
        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;
        client_max_body_size 0;
        proxy_http_version 1.1; 
        proxy_set_header Connection "";
        proxy_request_buffering off;
        #proxy_buffering off;
	proxy_next_upstream error timeout http_502 http_504;
    }

    location /orgsync/ {  
	#proxy_redirect off;
        proxy_set_header Host $host;
 	proxy_set_header X-Real-IP $remote_addr; 
	proxy_set_header REMOTE-HOST $remote_addr; 
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_pass http://orgsync:8989/; 
	index  index.html index.htm;
	allow all;
    }   

        location /Content/ {
                proxy_pass http://edoc2_ip/Content/; 
        		proxy_cache edoc2_cache; 
        		proxy_cache_key $request_uri; 
        		proxy_cache_methods GET HEAD; 
        		proxy_cache_valid  200 304 302 30d; 
        		proxy_cache_use_stale http_502; 
        		add_header X-Cache "$upstream_cache_status from $server_addr"; 
                proxy_set_header Host $http_host; 
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
                proxy_set_header X-Forwarded-Proto $scheme; 
        }   

       location /scripts/ {
                proxy_pass http://edoc2_ip/scripts/; 
                proxy_cache edoc2_cache; 
                proxy_cache_key $request_uri; 
                proxy_cache_methods GET HEAD; 
                proxy_cache_valid  200 304 302 30d; 
                proxy_cache_use_stale http_502; 
                add_header X-Cache "$upstream_cache_status from $server_addr"; 
                proxy_set_header Host $http_host; 
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
                proxy_set_header X-Forwarded-Proto $scheme; 
        } 

       location /lib/ {
                proxy_pass http://edoc2_ip/lib/; 
                proxy_cache edoc2_cache; 
                proxy_cache_key $request_uri; 
                proxy_cache_methods GET HEAD; 
                proxy_cache_valid  200 304 302 30d; 
                proxy_cache_use_stale http_502; 
                add_header X-Cache "$upstream_cache_status from $server_addr"; 
                proxy_set_header Host $http_host; 
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
                proxy_set_header X-Forwarded-Proto $scheme; 
        } 

       location /static/ {
                proxy_pass http://edoc2_ip/static/; 
                proxy_cache edoc2_cache; 
                proxy_cache_key $request_uri; 
                proxy_cache_methods GET HEAD; 
                proxy_cache_valid  200 304 302 30d; 
                proxy_cache_use_stale http_502; 
                add_header X-Cache "$upstream_cache_status from $server_addr"; 
                proxy_set_header Host $http_host; 
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
                proxy_set_header X-Forwarded-Proto $scheme; 
        } 

       location /Lang/ {
                proxy_pass http://edoc2_ip/Lang/; 
                proxy_cache edoc2_cache; 
                proxy_cache_key $request_uri; 
                proxy_cache_methods GET HEAD; 
                proxy_cache_valid  200 304 302 30d; 
                proxy_cache_use_stale http_502; 
                add_header X-Cache "$upstream_cache_status from $server_addr"; 
                proxy_set_header Host $http_host; 
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
                proxy_set_header X-Forwarded-Proto $scheme; 
        }                 

       location /image-upload/ {
                proxy_pass http://edoc2_ip/image-upload/; 
                proxy_cache edoc2_cache; 
                proxy_cache_key $request_uri; 
                proxy_cache_methods GET HEAD; 
                proxy_cache_valid  200 304 302 30d; 
                proxy_cache_use_stale http_502; 
                add_header X-Cache "$upstream_cache_status from $server_addr"; 
                proxy_set_header Host $http_host; 
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
                proxy_set_header X-Forwarded-Proto $scheme; 
        } 

       location /api/api-css/ {
                proxy_pass http://edoc2_ip/api/api-css/; 
                proxy_cache edoc2_cache; 
                proxy_cache_key $request_uri; 
                proxy_cache_methods GET HEAD; 
                proxy_cache_valid  200 304 302 30d; 
                proxy_cache_use_stale http_502; 
                add_header X-Cache "$upstream_cache_status from $server_addr"; 
                proxy_set_header Host $http_host; 
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
                proxy_set_header X-Forwarded-Proto $scheme; 
        }  

       location /api/api-js/ {
                proxy_pass http://edoc2_ip/api/api-js/; 
                proxy_cache edoc2_cache; 
                proxy_cache_key $request_uri; 
                proxy_cache_methods GET HEAD; 
                proxy_cache_valid  200 304 302 30d; 
                proxy_cache_use_stale http_502; 
                add_header X-Cache "$upstream_cache_status from $server_addr"; 
                proxy_set_header Host $http_host; 
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
                proxy_set_header X-Forwarded-Proto $scheme; 
        }   

       location /api/Content/ {
                proxy_pass http://edoc2_ip/api/Content/; 
                proxy_cache edoc2_cache; 
                proxy_cache_key $request_uri; 
                proxy_cache_methods GET HEAD; 
                proxy_cache_valid  200 304 302 30d; 
                proxy_cache_use_stale http_502; 
                add_header X-Cache "$upstream_cache_status from $server_addr"; 
                proxy_set_header Host $http_host; 
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
                proxy_set_header X-Forwarded-Proto $scheme; 
        }      
        
       location /api/images/ {
                proxy_pass http://edoc2_ip/api/images/; 
                proxy_cache edoc2_cache; 
                proxy_cache_key $request_uri; 
                proxy_cache_methods GET HEAD; 
                proxy_cache_valid  200 304 302 30d; 
                proxy_cache_use_stale http_502; 
                add_header X-Cache "$upstream_cache_status from $server_addr"; 
                proxy_set_header Host $http_host; 
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
                proxy_set_header X-Forwarded-Proto $scheme; 
        }    
        
       location /api/jquery/ {
                proxy_pass http://edoc2_ip/api/jquery/; 
                proxy_cache edoc2_cache; 
                proxy_cache_key $request_uri; 
                proxy_cache_methods GET HEAD; 
                proxy_cache_valid  200 304 302 30d; 
                proxy_cache_use_stale http_502; 
                add_header X-Cache "$upstream_cache_status from $server_addr"; 
                proxy_set_header Host $http_host; 
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
                proxy_set_header X-Forwarded-Proto $scheme; 
        } 

       location /external {
                proxy_pass http://edoc2_ip/external; 
                proxy_cache edoc2_cache; 
                proxy_cache_key $request_uri; 
                proxy_cache_methods GET HEAD; 
                proxy_cache_valid  200 304 302 30d; 
                proxy_cache_use_stale http_502; 
                add_header X-Cache "$upstream_cache_status from $server_addr"; 
                proxy_set_header Host $http_host; 
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
                proxy_set_header X-Forwarded-Proto $scheme; 
        } 
	#location ^~ /portainer/ {
	#	proxy_pass http://portainer:9000/;
	#	proxy_set_header X-Real-IP $remote_addr;
	#	proxy_set_header Host $http_host;
	#}

	location  /error/ {
		root /usr/share/nginx/html;
    }
	
	error_page 400 401 402 403 404 405 408 410 412 413 414 415  /400.html;
	location = /400.html {
	  root /usr/share/nginx/html/error;
    }
	
	#error_page  500 501 502 503 504 506 /500.html;
	#location = /500.html {
	#  root /usr/share/nginx/html/error;
    #}
    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    #error_page   500 502 503 504  /50x.html;
    #location = /50x.html {
    #    root   /usr/share/nginx/html;
    #}

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}





