nginx搭建文件服务器

在部署了各种应用后,产生的日志文件,需要在线下载查看,不用每次登陆服务器去拿;

这里,因为服务器部署了很多的应用程序,可以建一个主目录mylog,在主目录里用软连接将需要的各个日志文件夹都建好连接 ln -s 源文件夹/ 目标文件夹 后面不需要 /

在将主目录mylog配到nginx.conf ,这里有个主意的地方,就是nginx.conf里 user 要配置,否则报403禁止访问;

nginx.conf 配置如下:

 

user weblogic;
#user nobody;
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;
sendfile_max_chunk 256K;
tcp_nodelay on;
tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

"/etc/nginx/nginx.conf" 132L, 3126C
user weblogic;
#user nobody;
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;
sendfile_max_chunk 256K;
tcp_nodelay on;
tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
# client_max_body_size 8G;
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
}

location ^~ /cbblogs {
# alias /home/weblogic/apps/mylog;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/pass_file;
alias /home/nginx/mylog/;
charset utf-8;
autoindex on;
# autoindex_exact_size off; //
autoindex_localtime on;
autoindex_exact_size off;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;

...............

 

posted @ 2016-01-19 15:41  sl521100  阅读(792)  评论(0编辑  收藏  举报