应用平台 APPSTAGE-SLB实例配置:nginx配置

时间:2024-10-21 10:40:12

nginx配置

slb_instance_config/nginx.conf #nginx默认配置

#user  slb slb;
worker_processes auto;
#worker_cpu_affinity 0001 0010 0100 1000;
pid        logs/nginx.pid;
#####################################################################
### Default: Close the error log
error_log  /dev/null crit;
# nofile per worker around 20000-100000 is ok, eg, if have 8 worker, nginx will use no more than 8*worker_rlimit_nofile nofile, should make this result less than system nofile.
worker_rlimit_nofile 51200;
events {
    use epoll;
    # connections per worker, usually setup same or similar value as worker_rlimit_nofile.
    worker_connections 51200;
}
http {
    #####################################################################
    ### load basic lua script
    include 'lua/nginx.http.lua.conf';
    init_by_lua_file 'conf/lua/initial.lua';
    init_worker_by_lua_file 'conf/lua/initialWorker.lua';
    log_by_lua_file 'conf/lua/monitor/LogRequest.lua';
    #rewrite_by_lua_no_postpone on;
    #####################################################################
    uninitialized_variable_warn off;
    server_tokens off;
    autoindex off;
    port_in_redirect off;
    ssi off;
    proxy_hide_header X-Powered-By;
    add_header X-XSS-Protection "1; mode=block";
    add_header X-frame-options SAMEORIGIN;
    add_header X-Content-Type-Options  nosniff;
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains ";
    add_header Content-Security-Policy "default-src 'self'";
    add_header Cache-control "no-cache, no-store, must-revalidate";
    add_header Pragma no-cache;
    add_header Expires 0;
    client_header_timeout 60s;
    client_body_timeout 60s;
    keepalive_timeout 75s;
    send_timeout 60s;
    client_header_buffer_size 1k;
    large_client_header_buffers 4 8k;
    client_body_buffer_size 16k;
    client_max_body_size 1m;
    proxy_buffer_size 8k;
    proxy_buffers 8 8k;
    proxy_busy_buffers_size 16k;
    include mime.types;
    default_type text/html;
    #####################################################################
    ### gzip compress
    gzip on;
    gzip_http_version 1.1;
    gzip_comp_level 5;
    gzip_min_length 1k;
    gzip_disable "MSIE [1-6].";
    gzip_types
        text/plain text/css text/xml text/javascript
        application/json application/x-javascript application/xml application/xml+rss application/xhtml+xml;
    #####################################################################
    ### enabled the error page  process
    fastcgi_intercept_errors on;
    error_page 400 401 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 /4xx.html;
    error_page 500 501 502 503 504 505 /5xx.html;
    #####################################################################
    ### log format and switch.
    log_format  main  '$time_local|$request_time|$upstream_response_time|$uri'
        '|$status|$body_bytes_sent|$request_length|$bytes_sent|$http_user_agent|$http_host'
        '|$upstream_addr|$upstream_status|$scheme|$is_grey_server|$resp_status|$server_protocol';
    access_log logs/access.log  main buffer=5m flush=10s;
    log_format  bigData  '$time_local|$server_addr|$upstream_addr|$is_grey_server|$uri'
        '|$upstream_status|$resp_status|$request_time|$upstream_response_time|$request_length|$bytes_sent|$connections_active|$target_all|$remote_addr'
        '|$http_x_forwarded_for|$request_method|$http_user_agent|$status|$http_referer|$server_protocol|$body_bytes_sent|$request_length|$http_host|$request'
        '|$server_port|-|$http_x_api_method||||||||||';
    access_log logs/access_for_big_data.log  bigData buffer=5m flush=10s;
    #####################################################################
    ### load sub configure
    include vhosts/*.conf;
    include slb_conf/*.conf;
}
support.huaweicloud.com/devg-appstage/appstage_06_0088.html