#user nobody;
worker_processes 1;
user root;
#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 {
listen 8090;
server_name localhost;
location /e-commerce { ## 目錄下得e-commerce 子文件夾
root /www/files; ## 轉發到得父目錄
index index.html index.htm; #如果在斜線後面沒有任何內容,則會尋找 index.html
}
location /e-commerce-platform {
root /www/files;
index index.html index.htm;
}
location /m3u8 {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
root /www/files;
index index.html index.htm;
}
location /live { ## 反向代理
proxy_pass http://172.16.101.252:8888;
}
}
}
【注意nginx得機制 會自動得把上面得 /live 拼接 到http://172.16.101.252:8888/live 如果後面有添加奪得請求會自動向下拼接】
===
下面這個配置是轉發所有得文件:通用配置
server {
listen 8090;
server_name localhost;
location ~* / { ## 文件匹配 :只要是 /usr/local/cci/files/ 下面的目錄都轉發
root /usr/local/cci/files/;
index index.html index.htm;
}
location ~* \.(apk|gif|jpg|jpeg|png|bmp|doc|docx|ppt|pptx|pdf|xls|xlsx)$ { ## 文件匹配
root /usr/local/cci/files/;
expires 10d;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_ignore_client_abort on;
}
location /ds {
root /usr/local/cci/html/;
index index.html index.htm;
}