Nginx configuration on my red hat

Source: Internet
Author: User
User nobody Nobody;
# Start a process
Worker_processes 2;
# Global error logs and PID files
Error_log/var/log/nginx/error. Log notice;
Pid/var/log/nginx. PID;
# Working mode and maximum number of connections
Events {
Use epoll;
Worker_connections 1024;
}
# Set the HTTP server and use its reverse proxy function to provide Load Balancing support
HTTP {
# Set the MIME type
Include/etc/nginx/mime. types;
Default_type application/octet-stream;
# Set the log format
Log_format main '$ remote_addr-$ remote_user [$ time_local]'
'"$ Request" $ Status $ bytes_sent'
'"$ Http_referer" "$ http_user_agent "'
'"$ Gzip_ratio "';
Log_format download '$ remote_addr-$ remote_user [$ time_local]'
'"$ Request" $ Status $ bytes_sent'
'"$ Http_referer" "$ http_user_agent "'
'"$ Http_range" "$ sent_http_content_range "';
# Set Request Buffer
Client_header_buffer_size 1 K;
Large_client_header_buffers 4 4 K;
# Enable the gzip Module
Gzip on;
Gzip_min_length 1100;
Gzip_buffers 4 8 K;
Gzip_types text/plain;
Output_buffers 1 32 K;
Post pone_output 1460;
# Setting access log
Access_log/var/log/nginx/access. Log main;
Client_header_timeout 3 m;
Client_body_timeout 3 m;
Send_timeout 3 m;
Sendfile on;
Tcp_nopush on;
Tcp_nodelay on;
Keepalive_timeout 65;
# Set the Server list of Server Load balancer
Upstream mysvr {
# The weigth parameter indicates the weight. A higher weight indicates a higher probability of being assigned.
# Enable port 3128 for squid on the local machine
Server 192.168.0.1: 80 Weight = 1;
}
# Set Virtual Hosts
Server {
Listen 80;
SERVER_NAME 192.168.0.71
;
Charset gb2312;
# Set access logs for the current virtual host
Access_log/var/log/nginx/access. Log main;
# If you access/img/*,/JS/*,/CSS/* resources, you can directly retrieve the local file without passing squid
# This method is not recommended if there are many files, because the Squid cache works better.
Location ~ ^/(IMG | JS | CSS )/{
Root/data3/html;
Expires 24 h;
}
# Enable Server Load balancer "/"
Location /{
Proxy_pass http: // mysvr ;
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 10 m;
Client_body_buffer_size 128 K;
Proxy_connect_timeout 90;
Proxy_send_timeout 90;
Proxy_read_timeout 90;
Proxy_buffer_size 4 K;
Proxy_buffers 4 32 K;
Proxy_busy_buffers_size 64 K;
Proxy_temp_file_write_size 64 K;
}
# Set the address for viewing nginx status
Location/nginxstatus {
Stub_status on;
Access_log on;
Auth_basic "nginxstatus ";
Auth_basic_user_file CONF/htpasswd;
}
}
}
Related Article

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.