内容简介:在laradock添加文件夹,建议叫ngrok。文件夹下面存放三个文件。如:目录结构如下图所示:
准备工作
域名解析:
我的在:laradock - nginx - sites - [xxx.conf] 配置域名ngrok.yuling.net 或*.ngrok.yuling.net增加两条A记录解析到你的服务器。这样你可以使用subdomain的方式,来实现穿透。
如:
server {
listen 80;
listen [::]:80;
server_name ngrok.yuling.net *.ngrok.yuling.net;
root /var/www/yellow-croaker/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fixes timeouts
fastcgi_read_timeout 600;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
location /.well-known/acme-challenge/ {
root /var/www/letsencrypt/;
log_not_found off;
}
error_log /var/log/nginx/apidemo_error.log;
access_log /var/log/nginx/apidemo_access.log;
}
配置:
在laradock添加文件夹,建议叫ngrok。文件夹下面存放三个文件。
如:
image.png
目录结构如下图所示:
image.png
可以看到,有必须的Dockerfile文件,build.sh是编译ngrok的脚本,config.yml是客户端使用的配置文件,下面分别介绍下。
Dockerfile
FROM golang:1.7.1-alpine ADD build.sh / RUN apk add --no-cache git make openssl RUN git clone https://github.com/inconshreveable/ngrok.git --depth=1 /ngrok RUN sh /build.sh EXPOSE 8081 VOLUME [ "/ngrok" ] CMD [ "/ngrok/bin/ngrokd"]
基于golang:1.7.1-alpine这个镜像来构建
build.sh
#!/usr/bin/env bash export NGROK_DOMAIN="ngrok.yuling.net" cd /ngrok/ openssl genrsa -out rootCA.key 2048 openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=$NGROK_DOMAIN" -days 5000 -out rootCA.pem openssl genrsa -out device.key 2048 openssl req -new -key device.key -subj "/CN=$NGROK_DOMAIN" -out device.csr openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 5000 cp rootCA.pem assets/client/tls/ngrokroot.crt cp device.crt assets/server/tls/snakeoil.crt cp device.key assets/server/tls/snakeoil.key make release-server GOOS=linux GOARCH=386 make release-client GOOS=linux GOARCH=amd64 make release-client GOOS=windows GOARCH=386 make release-client GOOS=windows GOARCH=amd64 make release-client GOOS=darwin GOARCH=386 make release-client GOOS=darwin GOARCH=amd64 make release-client GOOS=linux GOARCH=arm make release-client
注意需要把上面的NGROK_DOMAIN修改为你自己的域名
构建镜像
有了这两个文件之后, cd ngrok 可以执行:
docker build -t ngrok . 或 docker build . -t ngrok 来构建镜像,如下图:
image.png
成功状态:
image.png
等执行完成之后,可以使用如下命令来启动:
docker run -it -p 8081:8081 -p 4443:4443 -v /Users/wenyuling/Desktop/Projects/laradock/ngrok/bin:/root/ngrok/bin/ -d ngrok /ngrok/bin/ngrokd -domain="ngrok.yuling.net" -httpAddr=":8081"
同样的,修改上述的 domain 为你自己的域名名同时路径: /Users/wenyuling/Desktop/Projects/laradock 改成自己的本地路径
客户端部分
打开ngrok官网: https://dashboard.ngrok.com/get-started ,选择性登录后如图所示:
image.png
按步骤1、2、3、4依次执行,即可。
1、
下载
2、
解压
3、
找到下载的目录,在终端执行: ./ngrok authtoken [你的 token]
我的目录如图所示:
image.png
4、
最后执行: ./ngrok http 80
看到如下输出,则说明成功了。
image.png
以上所述就是小编给大家介绍的《2018-12-05使用Docker部署Ngrok实现内网穿透》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Introduction to Linear Optimization
Dimitris Bertsimas、John N. Tsitsiklis / Athena Scientific / 1997-02-01 / USD 89.00
"The true merit of this book, however, lies in its pedagogical qualities which are so impressive..." "Throughout the book, the authors make serious efforts to give geometric and intuitive explanations......一起来看看 《Introduction to Linear Optimization》 这本书的介绍吧!