vim /etc/nginx/nginx.conf
user nginx;
worker_processes 8;
worker_processes auto;
worker_rlimit_nofile 51200;
server_tokens off;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_buffers 8 16k;
gzip_http_version 1.0;
gzip_vary on;
gzip_types text/* application/x-javascript application/*xml application/json;
client_max_body_size 16m;
client_body_timeout 64;
large_client_header_buffers 4 1024k;
fastcgi_buffer_size 16k;
fastcgi_buffers 8 1024k;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 1024M;
chunked_transfer_encoding off;
代理目录访问
location /couchdb {
rewrite /couchdb/(.*) /$1 break;
proxy_pass http://localhost:5984;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
转发域名访问
server {
server_name xiumisource.doufu.la;
location / {
proxy_pass http://img.xiumi.us;
}
}
TCP端口转发
stream {
upstream rds_doubi {
hash $remote_addr consistent;
server rdsoh476a30phc94h0ib.mysql.rds.aliyuncs.com:3306;
}
server {
listen 3309;
proxy_pass rds_doubi;
}
upstream local_mongo {
hash $remote_addr consistent;
server 127.0.0.1:27017;
}
server {
listen 12710;
proxy_pass local_mongo;
}
upstream couchdb {
hash $remote_addr consistent;
server 10.29.185.61:5984;
}
server {
listen 15984;
proxy_pass couchdb;
}
}
301跳转:
location / {
#root /mnt/www/webapp/public;
return 301 https://m.doufu.la$request_uri;
#root /mnt/www/doufu/web/m.doufu.la;
#index index.html;
#try_files $uri $uri/ /index.html;
}