標籤:設定檔 網站 動態
nginx.conf
root html; 網站目錄
core module : Main Events
Standard HTTP modules : Core Access FastCGI Gzip Log Proxy Rewrite Upstrem
通過官方查看模組協助 http://nginx.org/en/docs/
.
├── client_body_temp
├── conf
│ ├── fastcgi.conf 動態配置
│ ├── fastcgi.conf.default
│ ├── fastcgi_params 參數
│ ├── fastcgi_params.default
│ ├── koi-utf
│ ├── koi-win
│ ├── mime.types
│ ├── mime.types.default
│ ├── nginx.conf 靜態設定檔
│ ├── nginx.conf.default
│ ├── scgi_params
│ ├── scgi_params.default
│ ├── uwsgi_params
│ ├── uwsgi_params.default
│ └── win-utf
├── fastcgi_temp
├── html
│ ├── 50x.html 出錯
│ └── index.html
├── logs
│ ├── access.log
│ ├── error.log
│ └── nginx.pid
├── proxy_temp
├── sbin
│ └── nginx
├── scgi_temp
└── uwsgi_temp
egrep -v "#|^$" nginx.conf | cat -n
1 worker_processes 1; 和CPU核心數相當 效率
2 events {
3 worker_connections 1024; worker 可以接受最大多少個連結
4 }
5 http {
6 include mime.types;
7 default_type application/octet-stream;
8 sendfile on;
9 keepalive_timeout 65;
10 server {
11 listen 80;
12 server_name localhost; 網域名稱
13 location / {
14 root html;
15 index index.html index.htm;
16 }
17 error_page 500 502 503 504 /50x.html; 指定錯誤頁面
18 location = /50x.html {
19 root html;
20 }
21 }
22 }
開始配置
server {
listen 80;
server_name www.hequan.com;
root html/www;
index index.html index.htm;
}
server {
listen 80;
server_name blog.hequan.com;
root html/blog;
index index.html index.htm;
}
/sbin/nginx -s reload
301跳轉
server {
listen 80;
server_name hequan.com;
rewrite ^/(.*) http://www.hequan.com/$1 permanent;
}
解決惡意IP綁定
server {
listen 80;
location / {
deny all;
}
}
日誌切割
cd /application/nginx/logs && \
/bin/mv www_access.log www_access_$(date +%F -d -1day).log
/application/nginx/sbin/nginx -s reload
crontab -e
00 00 * * * /bin/sh /application/nginx/logs/xx.sh >/dev/null 2&1
日誌相關分析 awstats
200 正常 301 永久跳轉 403 禁止訪問 404 找不到請求的頁面 500 內部伺服器錯誤 502 壞的網關 503 服務當前不可用
本文出自 “何全” 部落格,請務必保留此出處http://hequan.blog.51cto.com/5701886/1767844
nginx簡單配置