user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    server_tokens off;
    limit_rate 1280K;
    limit_conn_zone $server_name zone=servers:10m; 
    limit_conn servers 200;
    include       /etc/nginx/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  /var/log/nginx/access.log  main;

    sendfile        on;
    keepalive_timeout  605;
    client_body_timeout 600s;
    client_header_timeout 10s;
    send_timeout 30s;
    server {
        listen       8000;
        server_name  localhost;

        access_log  /var/log/nginx/localhost.access.log  main;
        server_tokens off;
        limit_rate 1280K;
        limit_conn servers 200;
        keepalive_timeout  605;
        client_body_timeout 600s;
        client_header_timeout 10s;
        client_max_body_size 200M;
        send_timeout 30s;

        add_header Referrer-Policy "origin";
        add_header X-Permitted-Cross-Domain-Policies "none";
        add_header X-Download-Options "noopen";
        add_header X-Content-Type-Options "nosniff";
        add_header X-Frame-Options "DENY";
        
        #
        location ^~ /prod-api/ {
            proxy_set_header "X-UA-Compatible" "IE=Edge,chrome=1";
            proxy_pass         http://cwygl-server-prod:8080/;
            proxy_pass_header  Server;
            proxy_set_header   Host $http_host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        } 

        location /obs/ {
            proxy_pass         http://zhcw-prod.obs.telecomhb.com/;
        }  

        location /cdn/ {
            proxy_pass         http://zhcw-cdn.obs.telecomhb.com/;
        }        

        error_page  400 404 413 /50x.html;
        error_page  500 502 503 504  /50x.html;
                
        location / {
            proxy_set_header "X-UA-Compatible" "IE=Edge,chrome=1";
            root   /usr/share/nginx/html;
            index  index.html index.htm;
            if (!-e $request_filename) {
                rewrite ^(.*)$ /index.html?s=$1 last;
                break;
            }
            limit_rate 1280K;
            limit_conn servers 200;
        }

        location = /50x.html {
            root   /usr/share/nginx/html;
            limit_rate 1280K;
            limit_conn servers 200;
        }
    }
}  
