nginx搭建檔案伺服器

sl521100發表於2016-01-19

在部署了各種應用後,產生的日誌檔案,需要線上下載檢視,不用每次登陸伺服器去拿;

這裡,因為伺服器部署了很多的應用程式,可以建一個主目錄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;

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

 

相關文章