In doing recently uploaded pictures need to think how to upload pictures after the visit, because the back end is Node, start trying to write a special interface to find images by the incoming path, tried it does not feel good, because you want to set for each type of file Content-Type
, or change the browser will download the file directly.
koa-static scheme
Since the rear end of the frame is used koa, employed koa-static
to achieve the following:
import staticServer from 'koa-static';
app.use(staticServer(__dirname, '/upload'));
If upload
there are directory logo.png
file, you can through the URL http://cms.thinktxt.com/logo.png
access to.
Nginx program
Nginx naturally good at hosting static resources, and ultimately selected program is hosted by Nginx, so also can liberate Node service pressure, configuration is as follows:
server {
listen 80;
server_name cms.thinktxt.com;
location / {
大专栏 利用Nginx或koalass="kn">proxy_pass http://127.0.0.1:8080;
client_max_body_size 1000m;
}
location /images {
root e:/WorkSpace/Thinktxt-CMS/upload/;
}
}
If the upload
directory images
has a directory logo.png
file, you can through the URL http://cms.thinktxt.com/images/logo.png
access to.
If you want other systems to access other resources at the site directory, you can do the forwarding:
server {
listen 80;
server_name static.thinktxt.com;
location /images {
proxy_pass http://cms.thinktxt.com/images;
}
}