NGINX 상용 설정
1
2
3
http {
  server_tokens off;
}
nginx 기본 인증
1
htpasswd -c /usr/local/nginx/conf/nginx.passwd.db admin
1
htpasswd /usr/local/nginx/conf/nginx.passwd.db admin
1
2
3
4
location / {
    auth_basic "View is cheap,show me the password!";
    auth_basic_user_file nginx.passwd.db;
}
제한 $httpx_forwarded_for
1
2
3
4
5
6
7
8
9
10
set $allow false;
if ($http_x_forwarded_for = "185.199.111.153") {
  set $allow true;
}
if ($http_x_forwarded_for ~ "10.0.0.*") {
 set $allow true;
}
if ($allow = false) {
 return 404;
}
제한 요청 방법
1
2
3
if ($request_method !~ ^(GET|POST)$ ) {
    return 405;
}
필터 특수 UA
if ($http_user_agent ~* sqlmap|wget|curl) {return 403;}
그림 도 난 방지 체인
1
2
3
4
5
6
7
8
9
10
11
12
13
location /images/ {
    valid_referers none blocked lengyuewusheng.com www.lengyuewusheng.com;
    if ($invalid_referer) {
        return  403;
    }
}
 
location /images/ {
 valid_referers blocked lengyuewusheng.com www.lengyuewusheng.com;
 if ($invalid_referer) {
 rewrite ^/images/.*\.(gif|jpg|jpeg|png)$ /error.html last;
 }
}
역방향 에이전트 설정
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
http {
...
  upstream realservers {
 server 10.0.0.1:8080 weight=3;
 server 10.0.0.2:8080 weight=7;
 }
 server {
 location /admin/ { 
 proxy_pass http://realserver;
 proxy_set_header Host $host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-Proto $scheme;
 }
 }
}
nginx keepalive 오픈
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
upstream realserver {
    server 10.0.0.1:8080;
    keepalive 10;
    keepalive_timeout 60s;    # This directive appeared in version 1.15.3.
    keepalive_requests 100;   # This directive appeared in version 1.15.3.
}
http {
 keepalive_timeout 75s;
 server {
 location / {
 proxy_http_version 1.1;
 proxy_set_header Connection "";
 proxy_pass http://realserver;
 ...
 }
 }
}
nginx 디 렉 터 리 열기 보기
1
2
3
4
5
6
7
server {
    location /download/ {
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
 }
}
브 라 우 저 는 파일 내용 을 표시 하지 않 고 파일 을 직접 다운로드 합 니 다.
1
2
3
if ($request_filename ~* ^.*?\.(txt|pdf)$) {
    add_header Content-Disposition 'attachment';
}
nginx 사용자 실제 IP 가 져 오기
1
2
3
4
5
6
7
set_real_ip_from  10.0.0.0/8;               #           IP    IP ,     。
set_real_ip_from  192.168.0.0/16;
real_ip_header    X-Forwarded-For;          #   header      IP  。
real_ip_recursive on;                       #            IP。
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
nginx 강제 점프 https
1
2
3
4
5
6
7
if ( $scheme = http ){
    return 301 https://$server_name$request_uri;
}
 
if ( $scheme = http ){
 rewrite ^(.*)$ https://$host$1 permanent;
}
악의 에 못 이 겨 잡다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
http {
    geo $limited
    {
        default 1;
        10.0.0.0/8 0;
 123.207.144.220/32 0;
 36.110.170.248/30 0;
 118.184.170.248/30 0;
 }
 map $limited $limit {
 1 $binary_remote_addr;
 0 "";
 }
 limit_req_zone $limit zone=reqids:100m rate=10r/s;
 server {
 limit_req zone=reqids burst=2 nodelay;
 }
}
check_http_expect_alive [http 2xx | http 3xx | http 4xx | http 5xx] 지 정 된 HTTP 코드 를 되 돌려 줍 니 다.
nginx 를 통 해 txt 텍스트 파일 의 난 장 판 을 봅 니 다.
1
2
3
server:
    default_type 'text/html';
    charset utf-8,gbk;
질문
1
2
3
4
location / {
    autoindex on;
    autoindex_localtime on;
}
nginx try_files
nginx location @
nginx 캐 시 설정
nginx 는 uid 그 레이스 케 일 에 따라
nginx 동시 연결 수 제한
nginx 요청 주파수 제한
nginx 생존 검사
nginx upstream 백업 메커니즘
1
2
3
4
rewrite_log on;
proxy_ignore_client_abort on;
expires epoch;
관련 자료
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.