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
瀏覽器開始下載。。。
本文結束。