1. Inheritance

일반적으로 main context -> http context -> server context -> location context 로 내려가는 정직한 inheritance
2. 3가지 메인 Directive types
events {}
######################
# (1) Array Directive
######################
# Can be specified multiple times without overriding a previous setting
# Gets inherited by all child contexts
# Child context can override inheritance by re-declaring directive
access_log /var/log/nginx/access.log;
access_log /var/log/nginx/custom.log.gz custom_format;
http {
# Include statement - non directive
include mime.types;
server {
listen 80;
server_name site1.com;
# Inherits access_log from parent context (1)
}
server {
listen 80;
server_name site2.com;
#########################
# (2) Standard Directive
#########################
# Can only be declared once. A second declaration overrides the first
# Gets inherited by all child contexts
# Child context can override inheritance by re-declaring directive
root /sites/site2;
# Completely overrides inheritance from (1)
access_log off;
location /images {
# Uses root directive inherited from (2)
try_files $uri /stock.png;
}
location /secret {
#######################
# (3) Action Directive
#######################
# Invokes an action such as a rewrite or redirect
# Inheritance does not apply as the request is either stopped (redirect/response) or re-evaluated (rewrite)
return 403 "You do not have permission to view this.";
}
}
}'Tool > Nginx' 카테고리의 다른 글
| [NGINX] 3-9. Configuration - Worker Processes (0) | 2021.12.18 |
|---|---|
| [NGINX] 3-8. Configuration PHP Processing (0) | 2021.12.18 |
| [NGINX] 3-6. Configuration-Logging (0) | 2021.12.18 |
| [NGINX] 3-5. Configuration-try_files, Named Locations (0) | 2021.12.18 |
| [NGINX] 3-4. Configuration-Rewrites, Redirects (0) | 2021.12.18 |
댓글