An example of a complete nginx production configuration

Source: Internet
Author: User

User nobody nobody;

Worker_processes 4;

Worker_rlimit_nofile 51200;


Error_log Logs/error.log Notice;


Pid/var/run/nginx.pid;


Events {

Use Epoll;

Worker_connections 51200;

}


HTTP {

Server_tokens off;

Include Mime.types;


Proxy_redirect off;

Proxy_set_header Host $host;

Proxy_set_header X-real-ip $remote _addr;

Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;

Client_max_body_size 20m;

Client_body_buffer_size 256k;

Proxy_connect_timeout 90;

Proxy_send_timeout 90;

Proxy_read_timeout 90;

Proxy_buffer_size 128k;

Proxy_buffers 4 64k;

Proxy_busy_buffers_size 128k;

Proxy_temp_file_write_size 128k;


Default_type Application/octet-stream;

CharSet Utf-8;

Client_body_temp_path/var/tmp/client_body_temp 1 2;

Proxy_temp_path/var/tmp/proxy_temp 1 2;

Fastcgi_temp_path/var/tmp/fastcgi_temp 1 2;

Uwsgi_temp_path/var/tmp/uwsgi_temp 1 2;

Scgi_temp_path/var/tmp/scgi_temp 1 2;


Ignore_invalid_headers on;

Server_names_hash_max_size 256;

Server_names_hash_bucket_size 64;

Client_header_buffer_size 8k;

Large_client_header_buffers 4 32k;

Connection_pool_size 256;

Request_pool_size 64k;


Output_buffers 2 128k;

Postpone_output 1460;


Client_header_timeout 1m;

Client_body_timeout 3m;

Send_timeout 3m;



Log_format Main ' $server _addr $remote _addr [$time _local] $msec + $connection '

' $request ' $status $connection $request _time $body _bytes_sent "$http _referer"

' "$http _user_agent" "$http _x_forwarded_for";


Open_log_file_cache max=1000 inactive=20s Min_uses=1 valid=1m;


Access_log Logs/access.log Main;

Log_not_found on;



Sendfile on;

Tcp_nodelay on;

Tcp_nopush off;


Reset_timedout_connection on;

Keepalive_timeout 10 5;

Keepalive_requests 100;



gzip on;

Gzip_http_version 1.1;

Gzip_vary on;

Gzip_proxied any;

Gzip_min_length 1024;

Gzip_comp_level 6;

Gzip_buffers 8k;

Gzip_proxied expired No-cache no-store private auth no_last_modified No_etag;

Gzip_types text/plain application/x-javascript text/css application/xml Application/json;

Gzip_disable "MSIE [1-6]\. (?!. *SV1) ";



Upstream tomcat8080 {

Ip_hash;


Server 172.16.100.103:8080 weight=1 max_fails=2;

Server 172.16.100.104:8080 weight=1 max_fails=2;

Server 172.16.100.105:8080 weight=1 max_fails=2;

}


server {

Listen 80;

server_name www.magedu.com;

# Config_apps_begin

Root/data/webapps/htdocs;

Access_log/var/logs/webapp.access.log main;

Error_log/var/logs/webapp.error.log notice;


Location/{

Location ~* ^.*/favicon.ico$ {

Root/data/webapps;

Expires 180d;

Break

}

if (!-f $request _filename) {

Proxy_pass http://tomcat8080;

Break

}

}


Error_page 502 503 504/50x.html;

Location =/50x.html {

root HTML;

}

}


server {

Listen 8088;

server_name nginx_status;


Location/{

Access_log off;

Deny all;

return 503;

}


Location/status {

Stub_status on;

Access_log off;

Allow 127.0.0.1;

Allow 172.16.100.71;

Deny all;

}

}


}


This article is from the "gushing" blog, please be sure to keep this source http://zxt19880421.blog.51cto.com/8743763/1632229

An example of a complete nginx production configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.