Nginx anti-theft chain + static and dynamic separation + reverse proxy + cache + Load Balancing

Source: Internet
Author: User

Modify the nginx/conf/nginx.conf, after modifying the following:

User www www;worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid;events {worker_connections 1024;}    HTTP {include mime.types;    Default_type Application/octet-stream;  #log_format Main ' $remote _addr-$remote _user [$time _local] "$request" ' # ' $status $body _bytes_sent    "$http _referer" ' # ' "$http _user_agent" "$http _x_forwarded_for";    #access_log Logs/access.log Main;    Sendfile on;    #tcp_nopush on;    #keepalive_timeout 0;    Keepalive_timeout 65;    gzip on;    Gzip_min_length 1k;    Gzip_buffers 64k;    Gzip_http_version 1.1;    Gzip_comp_level 9;    Gzip_types text/plain application/x-javascript text/css application/xml; Gzip_vary on;upstream webservers{server 192.168.1.82;server 192.168.1.88;}    Proxy_cache_path/data/nginx/cache/webserver Levels=1:2 keys_zone=webserver:20m max_size=1g;server{Listen   80; server_name Song.com;index index.html idnex.htm;root/data0/htdocs/www;# .................................................... The chain of anti-theft ... #location. *\, ....                (|jpg|gif|png) $ {#root/data0/htdocs/www/;                #valid_referers None blocked *.demo.com demo.com 192.168.1.75;                        #if ($invalid _referer) {#rewrite ^/http://www.765h.com/error.html;                # return 403; #}#}#................................................... The anti-theft chain end....................# ..... ..... ..... ..... ..... ..... .....................  Module Cache # location/download {#root/data0/htdocs/www/;  #accesskey on;  # Accesskey_hashmethod MD5;  #accesskey_arg "Key"; #accesskey_signature "Mypass$remote_addr"; #}# ............................. ....................... ........ #add_header X-via $server _add             R #add_header x-cache $upstream _cache_status;# ........... .....................................        The static and dynamic separation ... location ~ (\.php) $ {proxy_pass http://webservers;;). }#......................................................end the static and dynamic separation ....... # ...................................................          Page Cache #location/{# root/data0/htdocs/www;   # index index.html index.php index.htm;         #proxy_pass http://webservers;          # Proxy_set_header X-real-ip $remote _addr;          # Proxy_cache webserver; #proxy_cache_valid 10m;#.........................................................end Page Cache #location/img/{#root      /data/img/;           #valid_referers none blocked *.demo.com demo.com;         #if ($invalid _referer) {# rewrite ^/http://www.demo.com/images/error.gif;   # #return 403;        #}#} #error_page 404/404.html; # REDIRECT Server error pages to the static page/50x.html # Error_page 500 502 503504/50x.html;        Location =/50x.html {root/data0/htdocs/www; } # Proxy The PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ {# ProX        Y_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 to. htaccess files, if Apache ' s document Root # concurs with Nginx ' s one # #l        ocation ~/\.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 5m;    # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers high:!anull:!    MD5;    # ssl_prefer_server_ciphers on;    # location/{# root HTML;    # index index.html index.htm; #    }    }

Nginx anti-theft chain + static and dynamic separation + reverse proxy + cache + Load Balancing

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.