nginx.conf 配置

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

erizhu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值