1、ngrok映射本机端口。
2、nginx代理ngrok映射的本机端口。
3、nginx配置静态资源路径。
举例如下:
1、ngrok http 8888
2、修改nginx.conf
server {
listen 8888;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#此处为静态资源配置
location ~ .*\.(gif|jpg|pdf|jpeg|png|exe)$
{
#root D:/nginx-1.15.5/temp/images/;#指定图片存放路径(可以放在nginx文件夹路径里也可以放其他p盘)
root D:/Tools/;
}
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
3、浏览器访问:http://bfd9c1ab.ngrok.io/文件名称带文件格式后缀。
例如:http://bfd9c1ab.ngrok.io/FeiQ.exe
浏览器开始下载。。。
本文结束。