1.
#user Nobody;
Worker_processes 2;
Events {
worker_connections 1024;
}
HTTP {
include mime.types;
Default_type Application/octet-stream;
Sendfile on;
Keepalive_timeout;
Upstream localhost{
#这里指定多个源服务器, IP: port, 80 port can write without writing
server 127.0.0.1:8080;
server {
listen;
server_name localhost;
Location/{
#启动代理
proxy_pass http://localhost
}
}}
2. Static file Configuration
#user nobody; Worker_processes 4 #推荐worker数为cpu核数, avoid CPU unnecessary context switch events {#表示每个worker进程所能建立连接的最大值 #一个nginx最大的连接数max =worker_conn
ections*worker_processes; #对于http请求本地资源最大并发数量为max #如果http作为反向代理, the maximum concurrency number is MAX/2.
Because each concurrency establishes a connection to the client and a connection to the backend service, it consumes two connections.
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;
Keepalive_timeout 65;
server {Listen 80;
server_name localhost;
#charset Koi8-r;
Access_log Logs/host.access.log Main;
#location/{# root HTML;
# index index.html index.htm;
#} location/{root e:/baidunetdiskdownload/boostrap3; #静态文件路径 Index index.html index.htm;
#访问首页, in the static file path root directory} # serve static files (Css|js|image ...) # #静态文件交给nginx处理 Location ~ *\. (HTM|HTML|GIF|JPG|JPEG|PNG|BMP|SWF|IOC|RAR|ZIP|TXT|FLV|MID|DOC|PPT|PDF|XLS|MP3|CSS|JS|TTF|WOFF|WOFF2) $ {#locati
On ~ ^/(img|javascript|js|css|flash|media|static)/{# img|javascript|js|css|flash|media|static corresponds to the folder under the static file path
Root e:/baidunetdiskdownload/boostrap3;
Access_log off;
Expires 30d;
} #error_page 404/404.html;
# REDIRECT Server error pages to the static page/50x.html # Error_page 502 503 504/50x.html;
Location =/50x.html {root html; }
}
}
For example: Access to 1.png images under IMG; http://127.0.0.1/img/1.png