server { }
server {
listen 80;
server_name example.org www.example.org;
...
}
server {
listen 80;
server_name example.net www.example.net;
...
}
server {
listen 80;
server_name example.com www.example.com;
...
}
Host
필드와 server_name
이 일치하는 서버로 라우트Host
필드가 없거나 일치하는 서버명이 없으면 default_server
로 라우트
(이 설정이 없으면 가장 첫 번째가 디폴트가 됨)location { }
server {
listen 80;
server_name example.org www.example.org;
root /data/www;
location / {
index index.html index.php;
}
location ~* \\.(gif|jpg|png)$ {
expires 30d;
}
location ~ \\.php$ {
fastcgi_pass localhost:9000;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}
}
/
는 모든 주소에 매치됨)/index.php?user=john&page=1
처럼 주소가 들어오면 인자를 제외한 URI 부분(/index.php
)만 사용nginx 설정 파일 예시
Configuring NGINX and NGINX Plus as a Web Server
간단 설정파일 작성
정적 콘텐츠 서버 설정