nginx 고급 설정

1865 단어 linux
방향 을 바꾸다
   if ($host != 'www.discuz.com'){
                rewrite ^/(.*)$  http://www.discuz.com/$1  permanent;
        }

1.사용자 인증
location ~ .*admin\.php {
                    auth_basic              "Auth";
                    auth_basic_user_file   /usr/local/nginx/conf/htpasswd;
                    include fastcgi_params;
                    fastcgi_pass unix:/tmp/www.sock;
                    fastcgi_index index.php;
                    fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;

            }

설명:뒤에 include 시작 은 phop 을 분석 하 는 데 사 용 됩 니 다.
이 부분 은 php 를 해석 하 는 설정 입 니 다.
 location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/tmp/www.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
    }

지정 한 로그&&도 난 방지 체인 을 기록 하지 않 습 니 다.
location ~ .*\.(gif|png|jpg|css|js|mp4|flv|rar|zip|swf|pdf|gz|bz2|doc)$ {
    access_log off;
    expires 1h;
    valid_referers none blocked server_names *.discuz.com;
    if ( $invalid_referer ) {
            return 403;
            #  rewrite     ;
            }
    }

로그 의 절단 은 스 크 립 트 로 이 루어 집 니 다.

좋은 웹페이지 즐겨찾기