user  root;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

#Unsecure connection mislead security
http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
	
    # set client body size to 2M #
    client_max_body_size 40M;

    #gzip  on;
    
	index  index.html index.htm;
    #
    # HTTPS server
    #
    server {
        listen       2463 default_server;
        listen       [::]:2463 ipv6only=on default_server;
        server_name  localhost;
        
        # This is Error for Same Port Redirection
        error_page 497  http://$host:$server_port$request_uri;

        access_log off;
    		#error_log off;
        ##########################################################################
        # Known issues : The cache and other modules which require shared memory # 
        #               support do not work on Windows Vista and later versions  #
        #               due to address space layout randomization being enabled  #
        #               in these Windows versions.                               #
        # ssl_session_cache   shared:SSL:10m;
        ##########################################################################

        # Fix for Defect SCGCQ00488803
        # This tag would not display Web Server information like version etc.
        # Hence removing the security vulnerability
        server_tokens off;
		
        root   html;
		
		add_header X-Frame-Options "SAMEORIGIN";
		add_header X-Content-Type-Options "nosniff" always;
		add_header Content-Security-Policy "default-src 'self'; font-src *;img-src * data:; script-src *; style-src *;";

		
        #charset koi8-r;

        #access_log  logs/host.access.log  main;
		
        # set client body size to 2M #
        client_max_body_size 40M;
        
	location / {
            #index  index.html index.htm;
            
            # setting Proxy
            proxy_redirect off;
            proxy_set_header Host $host:$server_port;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Ssl on;
			
            #Fix for Defect SCGCQ00502413
            # This tag would ensure that frame belongs to same origin
            # If any other application tries to overlay the screen, it would be prevented
            # This removing the possibility of clickjacking			
            add_header X-Frame-Options "SAMEORIGIN";
			add_header X-Content-Type-Options "nosniff" always;
			add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; font-src 'self' data:;" always;
			 # kill cache
        add_header Last-Modified $date_gmt;
        add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
        if_modified_since off;
        expires off;
        etag off;

        }

	# Upload form should be submitted to this location
         location ~* ^/lsi/storage/mr/api/1.0/servers/[0-9a-zA-Z\:\-\.]+/operations/upload\-file$ {
            # Pass altered request body to this location
            upload_pass   @test;

            # Store files to this directory
            # The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist
            upload_store upload_files 1;
            
            # Allow uploaded files to be read only by user
            upload_store_access user:rw;


            # Set specified fields in request body
            upload_set_form_field $upload_field_name.name "$upload_file_name";
	    
            #upload_set_form_field $upload_field_name.content_type "$upload_content_type";
            upload_set_form_field $upload_field_name.path "$upload_tmp_path";
	    
            #upload_pass_form_field "^submit$|^description$";
			
	    # whether uploads are resumable
	    upload_resumable on;
		
	    # maximum upload size (0 for unlimited)
	    upload_max_file_size 0;
	
	    # set client body size to 2M #
	    client_max_body_size 40M;
        }
		location ~* ^/lsi/storage/mr/api/1.0/servers/[0-9a-zA-Z\:\-\.]+/controllers/[0-9]+/slotgroups/[0-9]+/slots/[0-9]+/operations/import$ {
    			# Pass altered request body to this location
    			upload_pass   @test;

    			# Store files to this directory
    			# The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist
    			upload_store upload_certs ;

    			# Allow uploaded files to be read only by user
    			upload_store_access user:rw;


    			# Set specified fields in request body
    			upload_set_form_field $upload_field_name.name "$upload_file_name";

    			#upload_set_form_field $upload_field_name.content_type "$upload_content_type";
    			upload_set_form_field $upload_field_name.path "$upload_tmp_path";

    			#upload_pass_form_field "^submit$|^description$";

    			# whether uploads are resumable
    			upload_resumable on;

    			# maximum upload size (0 for unlimited)
    			upload_max_file_size 0;

    			# set client body size to 2M #
    			client_max_body_size 40M;
    	}
        location  ~* ^/lsi/storage/mr/api/1?\.?0?/?.*$ {
            include            fastcgi_params;
            fastcgi_pass       127.0.0.1:9009;
            fastcgi_read_timeout 150s;
        }
        # Pass altered request body to a backend
        location @test {
			include            fastcgi_params;
            fastcgi_pass       127.0.0.1:9009;
        }

        #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   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:9009
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9009;
        #    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;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

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

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
