Nginx德勤

来自ling
跳转至: 导航搜索
---------------E:\nginx\conf\nginx.conf--------
#user  nobody;
worker_processes  4;
error_log  E:/LOGS/nginx/error.log  error;
error_log  E:/LOGS/nginx/warn.log  warn;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    include includes/http.conf;
    
    server {
        listen       10000;
        server_name  test.com.cn;
        server_tokens off;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        access_log  E:/LOGS/nginx/access.log  main;
        include includes/common.conf;
        add_header X-Frame-Options SAMEORIGIN;
        add_header Set-Cookie "HttpOnly=true;Secure=true";

       location /aa { 
           rewrite ^ https://test.com.cn/aa permanent;                  
        }
        
        location ^~/aa/api/ver2.0/ {
           rewrite ^/aa/api/ver2.0/(.*)$ /$1 break;
           proxy_pass    http://gateway;
        }

        location /aa/ {
            alias  html/aa/;
            index  index.html index.htm;
        }

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }       
    }    
    upstream gateway {       
        server 10.0.0.1:10004 weight=100 max_fails=3 fail_timeout=30s;
        server 10.0.0.2:10004 weight=100 max_fails=3 fail_timeout=30s;         
    }  

}

---------E:\nginx\conf\includes\common.conf--------

## Increase this if you want to upload large attachments
client_max_body_size 500m;

gzip on;
gzip_vary on;
gzip_comp_level 6;
gzip_min_length 200;
gzip_types  text/plain
            text/xml
            text/css
            text/csv
            application/xml
            application/javascript
            application/x-javascript
            application/json
            application/octet-stream
            application/x-font-ttf
            application/rtf;

#access_log off;
error_log  E:/LOGS/nginx/10000_error.log;

----------------------E:\nginx\conf\includes\http.conf----------------

log_format  main  '$proxy_add_x_forwarded_for - $remote_addr - $remote_user [$time_local] [$msec] [$upstream_addr] [$upstream_response_time] [$request_time] [$http_host] "$request" '
                          '$status $body_bytes_sent "$request_body" "$http_referer" '
                          '"$http_user_agent" $http_x_forwarded_for';                  
proxy_cache_path temp/ 
  levels=1:2 
  keys_zone=fonts_cache:1m
  inactive=1d
  max_size=256m;

map $http_host $this_host {
    "" $host;
    default $http_host;
}

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;
    "" $this_host;
}

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

proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Forwarded-Host $the_host;
proxy_set_header X-Forwarded-Proto $the_scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_header_timeout 200s;
client_body_timeout 200s;
send_timeout 200s;     
proxy_connect_timeout 200s;
proxy_send_timeout 200s;
proxy_read_timeout 200s;