nginx 代理本地路径

一 : 业务目的:
使用nginx代理本地文件,使本地文件能供通过 localhost/test/index.html 路径 访问本地磁盘C:\Users\dengwubo\Desktop\test\index.html 目录

二: 实现步骤

  1. 下载nginx ---怎么下载就不谈了.

  2. 配置nginx.config

#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;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        #location  / {
            #proxy_pass http://127.0.0.1:8080;
      #  }
        
       # location  /api/ {
          # proxy_pass http://127.0.0.1:8088/;
      #  }
     location  /test {
            root C:\Users\dengwubo\Desktop;  # root 指的是匹配到"/" ,请大家参考
            index index.html;
        }
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容