1, 下载nginx
2, 下载nginx upload module模块
安装之前,也许需要安装 pcre
3,在nginx的解压目录下运行
--add-module 可以是相对路径,也可以是绝对路径, --prefix 安装的目录,一定要存在
6, nginx 配置参考文件 :包括thin的配置
wget http://nginx.org/download/nginx-1.3.0.tar.gz
解压
2, 下载nginx upload module模块
wget http://www.grid.net.ru/nginx/download/nginx_upload_module-2.2.0.tar.gz
解压
安装之前,也许需要安装 pcre
yum install pcre-devel
3,在nginx的解压目录下运行
./configure --prefix=/root/nginx --add-module=../nginx_upload_module-2.2.0/
--add-module 可以是相对路径,也可以是绝对路径, --prefix 安装的目录,一定要存在
4,make
6, nginx 配置参考文件 :包括thin的配置
user root;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
upload_resumable on;
client_max_body_size 100m;
listen 8888;
server_name localhost;
# Upload form should be submitted to this location
location /upload {
# Pass altered request body to this location
upload_pass @test;
upload_store /tmp 1;
upload_store_access user:r;
upload_set_form_field $upload_field_name[name] "$upload_file_name";
upload_set_form_field $upload_field_name[content_type] "$upload_content_type";
upload_set_form_field $upload_field_name[path] "$upload_tmp_path";
upload_aggregate_form_field "$upload_field_name[md5]" "$upload_file_md5";
upload_aggregate_form_field "$upload_field_name[size]" "$upload_file_size";
upload_pass_form_field "^submit$|^description$";
upload_cleanup 400 404 499 500-505;
}
# Pass altered request body to a backend
location @test {
proxy_pass http://mongrel;
}
}
server{
listen 30091;
root /var/www/sms/public/video;
}
upstream mongrel {
server 127.0.0.1:3001;
server 127.0.0.1:3002;
server 127.0.0.1:3003;
}
server {
upload_resumable on;
client_max_body_size 100m;
listen 3000;
root /var/www/sms/public;
access_log /var/www/sms/log/nginx.access.log;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
#upload video
location /upload_video {
# Pass altered request body to this location
upload_pass @rails;
upload_store /tmp 1;
upload_store_access user:r;
upload_set_form_field $upload_field_name[name] "$upload_file_name";
upload_set_form_field $upload_field_name[content_type] "$upload_content_type";
upload_set_form_field $upload_field_name[path] "$upload_tmp_path";
upload_aggregate_form_field "$upload_field_name[md5]" "$upload_file_md5";
upload_aggregate_form_field "$upload_field_name[size]" "$upload_file_size";
upload_pass_form_field "^submit$|^description$";
upload_cleanup 400 404 499 500-505;
}
# Upload image
location /upload_image {
# Pass altered request body to this location
upload_pass @rails;
upload_store /tmp 1;
upload_store_access user:r;
upload_set_form_field $upload_field_name[name] "$upload_file_name";
upload_set_form_field $upload_field_name[content_type] "$upload_content_type";
upload_set_form_field $upload_field_name[path] "$upload_tmp_path";
upload_aggregate_form_field "$upload_field_name[md5]" "$upload_file_md5";
upload_aggregate_form_field "$upload_field_name[size]" "$upload_file_size";
upload_pass_form_field "^submit$|^description$";
upload_cleanup 400 404 499 500-505;
}
# Pass altered request body to a backend
location @rails {
proxy_pass http://mongrel;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
# needed for HTTPS
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_max_temp_file_size 0;
if (-f $request_filename) {
break;
}
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://mongrel;
break;
}
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /var/www/sms/public;
}
}
}