
user  root;
worker_processes  1;

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


events {
    worker_connections  10000;
}


http {
    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;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    #include /etc/nginx/conf.d/*.conf;

    upstream gateway {
                 server 172.30.0.81;
                 #server 172.30.0.82;
             }

    upstream auth {
                 server 172.30.0.91:8100;
                 #server 172.30.0.92:8100;
             }

    server {
      listen       88;
      server_name  gateway;
      location / {
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_buffering off;
           proxy_pass http://gateway;
      }
    }

    server {
      listen       9000;
      server_name  auth;
      location / {
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_buffering off;
           proxy_pass http://auth;
      }
    }

    server {
        listen 443 ssl;
        server_name devgw.ininin.com;

        ssl_certificate     /etc/nginx/key/server.crt;
        ssl_certificate_key /etc/nginx/key/server.key;

        #access_log  /etc/nginx/key/access.log main ;
        #error_log /etc/nginx/key/error.log ;

        location / {
            proxy_redirect off;
            proxy_pass http://hostserverip:8000/;
        }
    }

    server {
      listen       8000;
      server_name  localhost;
      root         /usr/share/nginx/html;
      client_max_body_size 100m;
      location / {
           #若系统无法访问则放开下面的注释
           #root   html;
           index  index.html;
      }

      location ^~ /oauth/redirect {
           rewrite ^(.*)$ /index.html break;
      }

      location ^~ /api {
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_buffering off;
           rewrite ^/api/(.*)$ /$1 break;
           proxy_pass http://gateway;
	   proxy_connect_timeout 300s;
           proxy_read_timeout 300s;
           proxy_send_timeout 300s;
      }
    }

    server {
        listen       8081;
        server_name  localhost;
        root         /usr/share/nginx/app;
        client_max_body_size 100m;
        location = / {
                        index        index.html index.htm;
        }

      location ^~ /oauth/redirect {
           rewrite ^(.*)$ /index.html break;
      }

      location ^~ /api {
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_buffering off;
           rewrite ^/api/(.*)$ /$1 break;
           proxy_pass http://gateway;
      }
    }


    server {
        listen       8082;
        server_name  localhost;
        root         /usr/share/nginx/avue-data;
        client_max_body_size 100m;
        location / {
           index        index.html;
           error_page   404 /index.html;
       }
       location ^~ /blade-visual {
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_buffering off;
           proxy_pass http://gateway;
      }
    }


    server {
        listen       8083;
        server_name  localhost;
        root         /usr/share/nginx/label-designer;
        client_max_body_size 100m;
        location / {
           index        index.html;
           error_page   404 /index.html;
       }
      location ^~ /api {
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_buffering off;
           rewrite ^/api/(.*)$ /$1 break;
           proxy_pass http://gateway;
      }
    }


    server {
        listen       8090;
        server_name  localhost;

                location /api{
                        proxy_set_header Host $http_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://hostserverip:8091;
                }
                 location / {
                     root   /usr/share/nginx/di-web;
                           try_files $uri $uri/ /index.html;
                          index  index.html index.htm;
                 }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    
        
}
