欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Nginx 本地资源映射

程序员文章站 2022-07-10 20:00:18
...

nginx.conf 配置

 

#user  nobody;
worker_processes  1;


#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

	add_header Access-Control-Allow-Origin *;
	add_header Access-Control-Allow-Headers X-Requested-With;
	add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
    sendfile        on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    server {
        listen       8080;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }
		
		location /image{
			alias F:/faces/;		
		}
		
					
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

}

启动nginx

接下来就是访问了 浏览器输入localhost:8080/image/文件名

 

Nginx 本地资源映射