nginx配置文件

#user  nobody;
worker_processes  4;
error_log  /home/nginx/log/error.log error;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    accept_mutex on;
    multi_accept on;
    worker_connections  1024;
}


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;

    #gzip  on;
    client_max_body_size 100m;
    
    upstream bdms-back-service {
         server 10.255.35.77:8080;
         #server 10.20.79.168:8080;
    }
    
	
    upstream nlp-back-service {
        server 10.255.35.77:8081;
    }
    
    upstream recommend-service {
        server 10.255.35.77:8801;
        server 10.255.35.114:8801;
    }
	


    map $http_x_forwarded_proto $the_scheme {
        default $http_x_forwarded_proto;
        "" $scheme;
    }

    map $http_x_forwarded_host $the_host {
        default $http_x_forwarded_host;
        "" $host;
    }

    map $http_upgrade $proxy_connection {
        default upgrade;
        "" close;
    }

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $proxy_connection;
    proxy_set_header X-Forwarded-Proto $the_scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    
    server {
        listen       80;
        server_name  localhost;
        
        location /api/ {
            proxy_pass http://bdms-back-service/;
            proxy_http_version 1.1;
            proxy_set_header X-Forwarded-Host $the_host/api;
            proxy_set_header Host $host:$server_port;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $proxy_connection;
	    proxy_read_timeout 300s;
        }

        location /nlpws/ {
            proxy_pass http://nlp-back-service/;
            proxy_http_version 1.1;
            proxy_set_header X-Forwarded-Host $the_host/nlpws;
            proxy_set_header Host $host:$server_port;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $proxy_connection;
            proxy_read_timeout 300s;
        }
       
        location / {
            root   /home/changchengwebpage;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
            proxy_http_version 1.1;
            gzip   on;
		client_body_buffer_size 3m;
		client_max_body_size 3m;
        }

	location /bdms {
            alias   /home/bdmswebpage;
            index  index.html index.htm;
            try_files $uri $uri/ /bdms/index.html;
            proxy_http_version 1.1;
		client_body_buffer_size 3m;
		client_max_body_size 3m;
        }

        location /aip/ {
            proxy_pass http://recommend-service/;
            proxy_http_version 1.1;
            proxy_set_header X-Forwarded-Host $the_host/aip;
            proxy_set_header Host $host:$server_port;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $proxy_connection;
            proxy_read_timeout 300s;
        }

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


   
   
           
}
posted @ 2021-04-08 17:56  MaskerFan  阅读(78)  评论(0编辑  收藏  举报