Nginx configuration for a large company

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; set the version information of the server to be shut down in the client;

proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for; when there are multiple Nginx proxy servers in the backend, use this entry to record each forwarded IP

Client_max_body_size 20m; If the client is allowed to upload. , The maximum number of individual file sizes to limit uploads using this item;

Client_body_buffer_size 256k; sets the maximum cache that allows the client to upload data in physical memory;

Proxy_connect_timeout 90; set the proxy server back-end server request time-out to 90s;

Proxy_send_timeout 90; set the proxy server to send messages to the back-end server with a time-out 90s;

Proxy_read_timeout 90; set the proxy server to read messages sent by the backend server timeout period is 90s;

Proxy_buffers_size 128k; set the proxy server cache size to 128K ;

Proxy_buffers 4 64k; set the proxy server to have 4 segment cache space, each cache space size is 64k;

Client_body_temp_path/var/tmp/client_body_temp 1 2; sets the cache path on the disk when the client uploads data;

Proxy_temp_path/var/tmp/proxy_temp 1 2; set the proxy Server cache path

Fastcgi_temp_path/var/tmp/fastcgi_temp 1 2;

Uwscgi_temp_path/var/tmp/uwscgi_temp 1 2;

Scgi_temp_path/var/tmp/scgi_temp 1 2;

Ignore_invalid_headers on; ignoring the first message that cannot be understood;

Server_names_hash_max_size 256; The settings for these two items are binding Hash , it's going to be a lot faster.

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; ( the above items can be left to the default, if the server memory is large enough, you can adjust a bit larger )

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

$request "   $status   $connection   $request _time  $body _byets_sent  " "'

' " $http _user_agent " $http _x_forwarded_for ' ;( Setting the log format )

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

# Find a space in memory and set the log file cache to help improve performance

#max: Maximum cache number of entries

#inactive: How long is the inactivity period

#min_uses: minimum number of times to use

#valid: length of validity of the cache

Access_log Logs/access.log Main; setting up logs

Log_not_found on;

Sendfile on;

Tcp_nodelay on;

Tcp_nopush off;

Reset_timedout_connection on;

Keepalive_timeout 10 5;

Keepalive_requests 100; set the number of times a long link can request resources ;

gzip on;

Gzip_min_length 1k;

Gzip_buffers 4 16k;

Gzip_http_version 1.0;

Gzip_comp_level 2;

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

Gzip_vary on;

Gzip_proxied expired No-cache No-store private auth;

Gzip_disable "MSIE [1-6]\.";

Upstream tomcat8080 {

Ip_hash;

Server 172.16.100.103:8080 weight=1 max_fails=2;

Server 172.16.100.103:8080 weight=1 max_fails=2;

Server 172.16.100.103:8080 weight=1 max_fails=2;

}

server {

Listen 80;

server_name #####;

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; ( position of picture )

Expires 180d; Expiry Time

Break

}

If (!-f $request _filename) {

Proxy_pass http://tomcat8080; (if the file you are accessing does not exist, turn to the home page)

Break

}

}

Error_page 502 503 504/50x.html

Location =/50x.html {

Root html;

}

}

server {

Listen 8080;

server_name nginx_status; ( View server 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;

}

}

}


Nginx configuration for a large company

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.