ngnix 参考配置
阅读原文时间:2023年07月13日阅读:1

#user nobody;
worker_processes ;

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

#pid logs/nginx.pid;

events {
worker_connections ;
}

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"';

log\_format main-log '\[$request\_time\]$request|$msec|\[$time\_local\]|$remote\_addr|$http\_x\_forwarded\_for|$http\_user\_agent|$request\_body|$body\_bytes\_sent|$status';  
log\_format bdip17bim-log '\[$request\_time\]$request|$msec|\[$time\_local\]|$remote\_addr|$http\_x\_forwarded\_for|$http\_user\_agent|$request\_body|$body\_bytes\_sent|$status';

#access\_log  logs/access.log  main-log;

sendfile        on;  
#tcp\_nopush     on;

#keepalive\_timeout  ;  
keepalive\_timeout  ;  
client\_max\_body\_size 500M;  
client\_body\_buffer\_size 128k;

client\_header\_buffer\_size 8k;  
large\_client\_header\_buffers  8k;

gzip  on;  
gzip\_buffers  16k;  
#gzip\_http\_version 1.0;  
gzip\_comp\_level ;  
gzip\_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;  
gzip\_vary off;  
gzip\_disable "MSIE \[1-6\]\\.";

proxy\_connect\_timeout ;  
proxy\_send\_timeout ;  
proxy\_read\_timeout ;  
proxy\_buffer\_size 4k;  
proxy\_buffers  4k;  
proxy\_busy\_buffers\_size 64k;

server\_names\_hash\_max\_size ;  
server\_names\_hash\_bucket\_size ;

upstream modeltrans{  
    ip\_hash;  
    server 127.0.0.1: weight=;  
}

upstream bimdata{  
    server 127.0.0.1: weight=;  
}

server {  
    listen       ;  
    server\_name  192.168.0.66;  
    charset utf-;

    # location ~\* \\.(gif|jpg|jpeg|png|css|ico|html|htm|flv|mp4)$ {  
    #     #access\_log logs/static.lgsjbim.shlingang.com.log bdip17bim-log;  
    #     root E:/BDIP/ecology;  
    # }

    location /static {  
        autoindex on;  
        if ($request\_method = OPTIONS ) {  
            add\_header Access-Control-Allow-Origin $http\_origin;  
            add\_header Access-Control-Allow-Methods "GET, OPTIONS";  
            add\_header Access-Control-Allow-Headers "Authorization";  
            add\_header Access-Control-Allow-Credentials "true";  
            add\_header Content-Length ;  
            add\_header Content-Type "text/plain;charset=utf-8";  
            return ;  
        }

        add\_header Access-Control-Allow-Origin $http\_origin;  
        add\_header Access-Control-Allow-Credentials true;  
        add\_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;  
        add\_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS; 

        alias E:/BDIP/static.qiyeji.file/bdip-file/;  
        index index.html index.htm;  
    }

    location /lmv/static {  
        add\_header Access-Control-Allow-Origin $http\_origin;  
        add\_header Access-Control-Allow-Credentials true;  
        add\_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;  
        add\_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS;  
        index  index.jsp;  
        access\_log logs/static.lmv.lgsjbim.shlingang.com.log bdip17bim-log;  
        root E:/BDIP/apache-tomcat-7.0./webapps;  
    }

    location /lmv {  
        rewrite ^/lmv/(.\*)$ /$ last;  
        index  index.jsp;  
        add\_header Access-Control-Allow-Origin $http\_origin always;  
        add\_header Access-Control-Allow-Credentials true always;  
        add\_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type always;  
        add\_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS always;  
        access\_log logs/lmv.lgsjbim.shlingang.com.log bdip17bim-log;  
        proxy\_pass         http://127.0.0.1:8091;  
        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;  
        proxy\_set\_header X-Forwarded-Proto $scheme;  
    }

    location /rest/ {  
        add\_header Access-Control-Allow-Origin $http\_origin;  
        add\_header Access-Control-Allow-Credentials true;  
        add\_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;  
        add\_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS;  
        proxy\_pass http://modeltrans;  
        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;  
        proxy\_set\_header X-Forwarded-Proto $scheme;  
    }

    location ^~ /4DAnalog/ {  
        proxy\_pass http://127.0.0.1:8091;  
        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;  
        proxy\_set\_header X-Forwarded-Proto $scheme;  
    }

    location ^~ /is/ {  
        proxy\_pass http://127.0.0.1:8091;  
        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;  
        proxy\_set\_header X-Forwarded-Proto $scheme;  
    }

    location ^~ /filebim/ {  
        proxy\_pass http://127.0.0.1:8091;  
        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;  
        proxy\_set\_header X-Forwarded-Proto $scheme;  
    }

    location /{  
            add\_header Access-Control-Allow-Origin $http\_origin;  
            add\_header Access-Control-Allow-Credentials true;  
            add\_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;  
            add\_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS;  
            index  index.jsp;  
            access\_log logs/lgsjbim.shlingang.com.log bdip17bim-log;  
            proxy\_pass         http://127.0.0.1:8190;  
            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;  
            proxy\_set\_header X-Forwarded-Proto $scheme;  
    }  
}

server {  
    listen       ;  
    server\_name  lmv.lgsjbim.shlingang.com;  
    #charset utf-;  
    default\_type 'text/html';  
    charset utf-;  
    client\_max\_body\_size 500M;  
    root E:/WEAVER/Tomcat/webapps;

    location ~\* \\.(gif|jpg|jpeg|png|css|js|ico|html|htm|swf|zip|rar|json|rvt|svf|f2d|pf|gz|bin|db|pack|bat|dds|sdb)$ {  
        if ($request\_method = OPTIONS ) {  
            add\_header Access-Control-Allow-Origin $http\_origin;  
            add\_header Access-Control-Allow-Methods "GET, OPTIONS";  
            add\_header Access-Control-Allow-Headers "Authorization";  
            add\_header Access-Control-Allow-Credentials "true";  
            add\_header Content-Length ;  
            add\_header Content-Type "text/plain;charset=utf-8";

            return ;  
        }  
        add\_header Access-Control-Allow-Origin $http\_origin always;  
        add\_header Access-Control-Allow-Credentials true always;  
        add\_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type always;  
        add\_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS always;  
        access\_log logs/static.lmv.lgsjbim.shlingang.com.log bdip17bim-log;  
    }

    location /{  
        index  index.jsp;  
        add\_header Access-Control-Allow-Origin $http\_origin always;  
        add\_header Access-Control-Allow-Credentials true always;  
        add\_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type always;  
        add\_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS always;  
        access\_log logs/lmv.lgsjbim.shlingang.com.log bdip17bim-log;  
        proxy\_pass         http://127.0.0.1:8191;  
        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;  
        proxy\_set\_header X-Forwarded-Proto $scheme;  
    }  
}

}

#user  nobody;worker_processes  4;
#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;}

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"';
    log_format main-log '[$request_time]$request|$msec|[$time_local]|$remote_addr|$http_x_forwarded_for|$http_user_agent|$request_body|$body_bytes_sent|$status';    log_format bdip17bim-log '[$request_time]$request|$msec|[$time_local]|$remote_addr|$http_x_forwarded_for|$http_user_agent|$request_body|$body_bytes_sent|$status';
    #access_log  logs/access.log  main-log;
    sendfile        on;    #tcp_nopush     on;
    #keepalive_timeout  0;    keepalive_timeout  65;    client_max_body_size 500M;    client_body_buffer_size 128k;
    client_header_buffer_size 8k;    large_client_header_buffers 4 8k;
    gzip  on;    gzip_buffers 4 16k;    #gzip_http_version 1.0;    gzip_comp_level 2;    gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;    gzip_vary off;    gzip_disable "MSIE [1-6]\.";
    proxy_connect_timeout 90;    proxy_send_timeout 90;    proxy_read_timeout 90;    proxy_buffer_size 4k;    proxy_buffers 32 4k;    proxy_busy_buffers_size 64k;
    server_names_hash_max_size 512;    server_names_hash_bucket_size 128;
        upstream modeltrans{        ip_hash;        server 127.0.0.1:10002 weight=10;    }
    upstream bimdata{        server 127.0.0.1:11001 weight=10;    }                server {        listen       8090;        server_name  192.168.0.66;        charset utf-8;
        # location ~* \.(gif|jpg|jpeg|png|css|ico|html|htm|flv|mp4)$ {        #     #access_log logs/static.lgsjbim.shlingang.com.log bdip17bim-log;        #     root E:/BDIP/ecology;        # }                location /static {            autoindex on;            if ($request_method = OPTIONS ) {                add_header Access-Control-Allow-Origin $http_origin;                add_header Access-Control-Allow-Methods "GET, OPTIONS";                add_header Access-Control-Allow-Headers "Authorization";                add_header Access-Control-Allow-Credentials "true";                add_header Content-Length 0;                add_header Content-Type "text/plain;charset=utf-8";                return 200;            }
            add_header Access-Control-Allow-Origin $http_origin;              add_header Access-Control-Allow-Credentials true;            add_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;            add_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS; 
            alias E:/BDIP/static.qiyeji.file/bdip-file/;            index index.html index.htm;        }
        location /lmv/static {            add_header Access-Control-Allow-Origin $http_origin;            add_header Access-Control-Allow-Credentials true;            add_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;            add_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS;            index  index.jsp;            access_log logs/static.lmv.lgsjbim.shlingang.com.log bdip17bim-log;            root E:/BDIP/apache-tomcat-7.0.75/webapps;        }
        location /lmv {            rewrite ^/lmv/(.*)$ /$1 last;            index  index.jsp;            add_header Access-Control-Allow-Origin $http_origin always;            add_header Access-Control-Allow-Credentials true always;            add_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type always;            add_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS always;            access_log logs/lmv.lgsjbim.shlingang.com.log bdip17bim-log;            proxy_pass         http://127.0.0.1:8091;            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;            proxy_set_header X-Forwarded-Proto $scheme;        }
        location /rest/ {            add_header Access-Control-Allow-Origin $http_origin;            add_header Access-Control-Allow-Credentials true;            add_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;            add_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS;            proxy_pass http://modeltrans;            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;            proxy_set_header X-Forwarded-Proto $scheme;        }                location ^~ /4DAnalog/ {              proxy_pass http://127.0.0.1:8091;             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;            proxy_set_header X-Forwarded-Proto $scheme;        }
        location ^~ /is/ {              proxy_pass http://127.0.0.1:8091;             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;            proxy_set_header X-Forwarded-Proto $scheme;         }                location ^~ /filebim/ {              proxy_pass http://127.0.0.1:8091;             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;            proxy_set_header X-Forwarded-Proto $scheme;         }                location /{                add_header Access-Control-Allow-Origin $http_origin;                add_header Access-Control-Allow-Credentials true;                add_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;                add_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS;                index  index.jsp;                access_log logs/lgsjbim.shlingang.com.log bdip17bim-log;                proxy_pass         http://127.0.0.1:8190;                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;                proxy_set_header X-Forwarded-Proto $scheme;        }    }

server {        listen       8003;        server_name  lmv.lgsjbim.shlingang.com;        #charset utf-8;        default_type 'text/html';        charset utf-8;        client_max_body_size 500M;        root E:/WEAVER/Tomcat/webapps;
        location ~* \.(gif|jpg|jpeg|png|css|js|ico|html|htm|swf|zip|rar|json|rvt|svf|f2d|pf|gz|bin|db|pack|bat|dds|sdb)$ {            if ($request_method = OPTIONS ) {                add_header Access-Control-Allow-Origin $http_origin;                add_header Access-Control-Allow-Methods "GET, OPTIONS";                add_header Access-Control-Allow-Headers "Authorization";                add_header Access-Control-Allow-Credentials "true";                add_header Content-Length 0;                add_header Content-Type "text/plain;charset=utf-8";                                return 200;            }            add_header Access-Control-Allow-Origin $http_origin always;            add_header Access-Control-Allow-Credentials true always;            add_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type always;            add_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS always;            access_log logs/static.lmv.lgsjbim.shlingang.com.log bdip17bim-log;        }
        location /{            index  index.jsp;            add_header Access-Control-Allow-Origin $http_origin always;            add_header Access-Control-Allow-Credentials true always;            add_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type always;            add_header Access-Control-Allow-Methods HEAD,GET,POST,PUT,DELETE,OPTIONS always;            access_log logs/lmv.lgsjbim.shlingang.com.log bdip17bim-log;            proxy_pass         http://127.0.0.1:8191;            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;            proxy_set_header X-Forwarded-Proto $scheme;        }    }    }