user  root;
worker_processes  auto;

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


events {
    worker_connections  1024;
}


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;
	gzip on;
	gzip_min_length 1k;
	gzip_comp_level 9;
	gzip_types text/plain application/x-javascript text/javascript application/x-httpd-php text/css text/xml text/jsp application/eot application/ttf application/otf application/svg application/woff application/javascript application/xml image/jpeg image/gif image/png;
	gzip_vary on;
	gzip_disable "MSIE [1-6].";
    # 除去 Web 站点中的信用卡号
    sub_filter '(\d{4}[- ]?){3}\d{4}' '**** **** **** ****';
    sub_filter_once off;

	# 全局设置允许的最大请求体大小
    client_max_body_size 2048m;

	server {
			listen	80;
			server_name	localhost;
			location ^~/bqw-ai {
				proxy_pass	http://bqw-ai-system:8080/bqw-ai;
				proxy_set_header Host 127.0.0.1;
				proxy_set_header X-Real-IP $remote_addr;
				proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
				proxy_set_header Upgrade $http_upgrade;
    			proxy_set_header Connection "upgrade";

                # 允许跨域请求
                add_header Access-Control-Allow-Origin *;
                # 允许带身份验证信息的跨域请求
                add_header Access-Control-Allow-Credentials true;
                # 允许的请求方法
                add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
                # 允许的请求头
                add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
                # 预检请求的有效期
                add_header Access-Control-Max-Age 3600;
                # 处理 OPTIONS 请求
                if ($request_method = 'OPTIONS') {
                    add_header Content-Type 'text/plain; charset=utf-8';
                    add_header Content-Length 0;
                    return 204;
                }
			}

			location /bqw-ai/websocket {
			    proxy_pass http://bqw-ai-system:8080/bqw-ai/websocket;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_read_timeout 900s;
			}

		      	location / {
                root /usr/share/nginx/html/;
                index  index.html index.htm;
                if (!-e $request_filename) {
                    rewrite ^(.*)$ /index.html?s=$1last;
                    break;
                }
            }

          location /h5_client {
            alias /usr/share/nginx/llm_flow/;
            index index.html index.htm;
          }

         location /electron_h5 {
              alias /usr/share/nginx/electron_h5/;
              index index.html index.htm;
         }

            # http://10.180.6.206
			# https://xtbg.lg.gov.cn/LGOA


          location /LGOA  {
               proxy_pass   https://xtbg.lg.gov.cn/LGOA;
          }
          location /OAZS  {
               proxy_pass   http://10.180.6.206/OAZS;
          }


            location /magic {
                proxy_pass	http://bqw-ai-magic:9999/magic;
            }





            location /magic/web/console {
              proxy_pass	http://bqw-ai-magic:9999/magic/web/console;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "upgrade";
              proxy_read_timeout 900s;
            }


            # minio-api
            location /minio-api/ {
                proxy_pass	http://bqw-ai-minio:9000/;
            }

            #minio页面
            location /minio/login {
                proxy_pass http://bqw-ai-minio:9011;
                # 启用支持websocket连接
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                client_max_body_size 1024m;
                proxy_http_version 1.1;
                proxy_connect_timeout 3600;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Forwarded-Host $http_host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            }


		    	location /bqw-ai/sys/common/static/bqw-ai-file/  {
                proxy_pass http://bqw-ai-minio:9000/bqw-ai-file/;

                # 可选：添加一些常用的代理设置
                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_set_header X-Forwarded-Proto $scheme;

                # 如果需要处理大文件上传或下载，可以调整超时时间
                proxy_connect_timeout 600;
                proxy_send_timeout 600;
                proxy_read_timeout 600;
            }


            location /h5_client/bqw-ai-file/ {
                proxy_pass http://bqw-ai-minio:9000/bqw-ai-file/;

                # 可选：添加一些常用的代理设置
                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_set_header X-Forwarded-Proto $scheme;

                # 如果需要处理大文件上传或下载，可以调整超时时间
                proxy_connect_timeout 600;
                proxy_send_timeout 600;
                proxy_read_timeout 600;
            }



	    location /bqw-video/ {
		    proxy_pass http://10.102.8.55:8090/;

		                    # 可选：添加一些常用的代理设置
		    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_set_header X-Forwarded-Proto $scheme;

		                    # 如果需要处理大文件上传或下载，可以调整超时时间
		    proxy_connect_timeout 600;
		    proxy_send_timeout 600;
		    proxy_read_timeout 600;
	    }


		location /bqw-ai-file/ {
			proxy_pass http://bqw-ai-minio:9000/bqw-ai-file/;

							# 可选：添加一些常用的代理设置
			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_set_header X-Forwarded-Proto $scheme;

							# 如果需要处理大文件上传或下载，可以调整超时时间
			proxy_connect_timeout 600;
			proxy_send_timeout 600;
			proxy_read_timeout 600;
		}










	}
    server {

            listen	8081;
            server_name	localhost;

            client_max_body_size 2000M;

            # minio-api
            location / {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header Host $http_host;

                proxy_connect_timeout 300;
                # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
                proxy_http_version 1.1;
                proxy_set_header Connection "";
                chunked_transfer_encoding off;

                proxy_pass	http://bqw-ai-minio:9000/;
           }


    }

    server {
            listen	8080;
            server_name	localhost;



            # minio-api
            location /minio-api/ {
                proxy_pass	http://bqw-ai-minio:9000/;
            }

            #minio页面
            location / {
                proxy_pass http://bqw-ai-minio:9011;
                # 启用支持websocket连接
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                client_max_body_size 1024m;
                proxy_http_version 1.1;
                proxy_connect_timeout 3600;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Forwarded-Host $http_host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            }

    }

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