Complete nginx. conf cluster configuration

Source: Internet
Author: User
Tags nginx reverse proxy
############################### Nginx. complete configuration of the conf cluster ############################### user nobody; # user main module command, command nginx worker to run users and user groups (User xxxuser xxxgroup). By default, worker_processes 1 is run by nobody; # worker_processes main module command, command number of processes run by nginx, each process consumes 10 Mbit/s of memory on average, with one core and N # error_log logs/error for multiple cores. log; # global log output levels: Debug, info, notice, warn, error, and crit. Among them, debug output logs are the most detailed # error_log logs/error. log notice; # level notice # error_log logs/erro R. log Info; # level info # PID logs/nginx. PID; # PID command specifies the process ID storage location events {worker_connections 1024; # events command nginx working mode and connection limit} HTTP {# HTTP server configuration include mime. types; # contains the file mime. types default_type application/octet-stream; # The default value is binary stream # log format setting # log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request"' # commands of the httplog module and log output format, main is the log name, which can be referenced in the access_log command # '$ Status $ body_bytes_sent "$ http_referer "' # '"$ Http_user_agent" "$ http_x_forwarded_for"'; # access_log logs/access. log main; sendfile on; # efficient file transmission mode. Set tcp_nopush and tcp_nodely to on # tcp_nopush on; # keepalive_timeout 0; # timeout time for client connection persistence, disconnect keepalive_timeout 65 after timeout; # gzip on; # enable gzip compression for real-time compression of output data streams # server VM configuration 1 server {Listen 80; # port SERVER_NAME www.luozhonghua1.com; # IP or domain name, multiple www.abc.com, 127.0.0.1 # charset koi8-r; # encoding format access_log logs/luozhon Ghua1.access. log main; # location/{# Root HTML; index index.html index.htm; root/web/www/luozhonghua1.com/htdocs;}# error_page 404/404 .html; # redirect server error pages to the static page/50x.html # error_page 500 502 503 504/50 x.html; # location =/50x.html {root HTML ;} # Server Virtual Host Configuration 2 server {Listen 80; # port SERVER_NAME www.luozhonghua2.com; # IP address or domain name, multiple www.abc.com, 127.0.0.1 # Charset koi8-r; # encoding format access_log logs/luozhonghua2.access. log main; # location/{# Root HTML; index index.html index.htm; root/web/www/luozhonghua2.com/htdocs;}# error_page 404/404 .html; # redirect server error pages to the static page/50x.html # error_page 500 502 503 504/50 x.html; # location =/50x.html {root HTML ;} # Server Virtual Host Configuration 3 include/usr/local/nginx/CONF/vhosts/www. lu Ozhonghua2.com. conf; ####/usr/local/nginx/CONF/vhosts/www.luozhonghua2.com. conf # server {# Listen 80; # SERVER_NAME www.luozhonghua3.com # access_log logs/luozhonghua3.access. log. main; # location/{# index index.html; # root/web/www/luozhonghua3.com/htdocs;#}#####/usr/local/nginx/CONF/vhosts/www.luozhonghua2.com. conf # nginx Reverse Proxy Server Load balancer configuration upstream myserver {server 192.168.1.101: 80 Weight = 3 Max _ Fails = 3 fail_timeout = 20 s; server 192.168.1.102: 80 Weight = 1 max_fails = 3 fail_timeout = 20 s; server 192.168.1.103: 80 Weight = 4 max_fails = 3 fail_timeout = 20 s ;} server {Listen 80; SERVER_NAME 255.192.168.1.100; index index.htm index.html root/web/root; Location/{proxy_pass http: // myserver; proxy_next_upstream http_500 http_502 http_503 error timeout invalid_header; include/usr/local/ Nginx/CONF/proxy. conf ;}#######/usr/local/nginx/CONF/proxy. CONF file content # proxy_redirect off; # proxy_set_header host $ host; # proxy_set_header X-real-IP $ remote_addr; # proxy_set_header X-forwarded-for $ scheme; # limit 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; ###### proxy. conf file content # anti-theft link setting location ~ *\. (JPG | GIF | PNG | SWF | FLV | WMA | WMV | ASF | MP3 | MMF | zip | RAR) $ {valid_referers none blocked * .luozhonghua.com luozhonghua.com; if ($ invalid_referer) {rewrite ^/http://www.luozhonghua.com/img/error.gif # Return 403;} location/images {root/usr/local/nginx/html; valid_referers none blocked * .luozhonghua.com luozhonghua.com; if ($ invalid_referer) {return 403 ;}}# log segmentation configuration #/bin/bash savepath_log = '/home/nginx /Logs' # log storage path after segmentation nglogs = '/usr/local/nginx/logs' # nginx log file storage path mkdir-p $ savepath_log/$ (date + % Y) /$ (date + % m) mV $ nglogs/access. log $ savepath_log/$ (date + % Y)/$ (date + % m)/access. $ (date + % Y % m % d ). log MV $ nglogs/error. log $ savepath_log/$ (date + % Y)/$ (date + % m)/error. $ (date + % Y % m % d ). log kill-usr1 'cat/usr/local/nginx/logs/nginx. PID '# achieve automatic log switching through the nginx signal usr1 # proxy the PHP scripts to Apache listening on 12 7.0.0.1: 80 # location ~ \. Php $ {# proxy_pass http: // 127.0.0.1; #}# pass the PHP scripts to FastCGI server listening on 127.0.0.1: 9000 # location ~ \. PHP $ {# Root HTML; # fastcgi_pass 127.0.0.1: 9000; # fastcgi_index index. PHP; # fastcgi_param script_filename/scripts $ fastcgi_script_name; # include fastcgi_params; #}# deny access. htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\. HT {# deny all ;#}# another virtual host using mix of IP-, name-, and port-based configuration # server {# listen 8000; # Listen somename: 8080; # SERVER_NAME somename alias another. alias; # location/{# Root HTML; # index index.html index.htm; #}#}# https server # server {# Listen 443; # SERVER_NAME localhost; # SSL on; # ssl_certificate cert. PEM; # ssl_certificate_key cert. key ;# Ssl_session_timeout 5 m; # ssl_protocols SSLv2 SSLv3 tlsv1; # ssl_ciphers high :! Anull :! MD5; # ssl_prefer_server_ciphers on; # location/{# Root HTML; # index index.html index.htm ;#}#}}

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.