如今市场上出现了很多免费wifi,也就是商用路由器,其目的就是推送广告和app,推送android app比较简单,
直接通过路由器本地下载即可,但苹果应用要通过app store下载,给推广带来了很多麻烦。但苹果有个协议可以通过
浏览器点击直接安装,那就是先通过ssl访问plist文件,然后根据plist文件中的地址下载安装。
需要做以下工作:
1. 移植支持https的服务器,一般用nginx
2.申请证书
3. dns重定向
搭建https服务器
nginx的配置选项
NGINX_HOME = $(shell pwd)/nginx-1.6.2
NGINX_VERSION=nginx-1.6.2
ROORDIR=/mnt/src
all: config_test
$(MAKE) -C $(NGINX_VERSION)
config_test:
echo "dir="$(ROOTDIR)
( if [ -f ./config_done ]; then \
echo "the same configuration"; \
else \
make configure; \
rm -f config_done; \
touch config_done; \
fi )
`echo '#ifndef NGX_SYS_NERR' >> $(NGINX_VERSION)/objs/ngx_auto_config.h`
`echo '#define NGX_SYS_NERR 132' >> $(NGINX_VERSION)/objs/ngx_auto_config.h`
`echo '#endif' >> $(NGINX_VERSION)/objs/ngx_auto_config.h`
`echo '#ifndef NGX_HAVE_SYSVSHM' >> $(NGINX_VERSION)/objs/ngx_auto_config.h`
`echo '#define NGX_HAVE_SYSVSHM 1' >> $(NGINX_VERSION)/objs/ngx_auto_config.h`
`echo '#endif' >> $(NGINX_VERSION)/objs/ngx_auto_config.h`
install:
$(MAKE) -C $(NGINX_VERSION) install
configure:
( cd $(NGINX_VERSION) ; \
./configure \
--prefix=/etc \
--sbin-path=/bin/nginx \
--conf-path=/etc/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/log/nginx.lock.accept \
--error-log-path=/dev/null \
--without-http_rewrite_module \
--without-http_gzip_module \
--without-http_proxy_module \
--without-http_userid_module \
--without-http_auth_basic_module \
--without-http_auth_basic_module \
--without-http_geo_module \
--without-http_map_module \
--without-http_split_clients_module \
--without-http_referer_module \
--without-http_rewrite_module \
--without-http_proxy_module \
--without-http_fastcgi_module \
--without-http_uwsgi_module \
--without-http_scgi_module \
--without-http_memcached_module \
--without-http_limit_conn_module \
--without-http_limit_req_module \
--without-http_empty_gif_module \
--without-http_upstream_ip_hash_module \
--without-http_upstream_least_conn_module \
--without-http_upstream_keepalive_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--with-http_ssl_module \
--with-openssl=$(ROOTDIR)/user/openssl-1.0.1c \
)
clean:
$(MAKE) -C $(NGINX_VERSION) clean
rm -rf install
rm -f config_done
distclean:
$(MAKE) -C $(NGINX_VERSION) clean
rm -rf install
rm -f config_done
romfs:
cp $(NGINX_HOME)/objs/nginx $(ROOTDIR)/romfs/bin
# cp $(NGINX_HOME)/conf/nginx.conf $(ROOTDIR)/etc_ro
# cp $(NGINX_HOME)/conf/mime.types $(ROOTDIR)/etc_ro
$(STRIP) $(ROOTDIR)/romfs/nginx
nginx和openssl源代码见附件,交叉编译时遇到了一系列问题
1.对于不同版本openssl,cross_compile的值不同,有些版本需要在nginx/objs Makefile中去除前缀,否则GCC 配置不正确。
2. 在openssl的一些模块的Makefile中需要指定库目录,增加-L../
3. nginx编译时会先去config openssl源码,路径如
--
with
-
openssl所配,config参数由nginx传入,编译完openssl后再完成
nginx的编译。
源码下载路径:
申请ssl证书
填写完信后会进入审核阶段,审核通过后会获得证书压缩包。(需要申请域名,并指定IP地址,解压密码为申请时填写的密码)
nginx在路由器设备中的运行
etc目录下要有两个文件, nginx.conf 和mime.types文件
如nginx.conf内容如下
# cat /etc/nginx.conf
worker_processes 1;
error_log /dev/null;
events {
worker_connections 50;
}
http {
include mime.types;
default_type application/octet-stream;
access_log /dev/null;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root /media/;
autoindex on;
autoindex_localtime on;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 443;
server_name localhost;
ssl on;
ssl_certificate /media/server.crt;
ssl_certificate_key /media/server.key;
location / {
root /media/;
autoindex on;
autoindex_localtime on;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
ssl_certificate 和
ssl_certificate_key 配置证书路径,配置的两个文件通过申请所得,需要放在配置的目录。
通过浏览器下载ios客户端需要按照苹果的协议下载plist配置文件,且下载plist文件必须通过ssl协议。
现将plist文件放在路由器本地,不联网也可以下载苹果app。
由于申请的证书文件为duxiaotian.xyz(私人域名),而如果直接访问路由器地址下载plist文件,浏览器会提示无法连接。
主要由证书验证出错导致,需要通过duxiaotian.xyz域名访问,在路由器中将该域名重定向到路由器本地地址即可.(dnsmasq 修改/etc/hosts文件,增加
192.168.1.1 duxiaotian.xyz ssl)
plist文件中需要配置app下载地址为路由器地址,不要求ssl加密传输。
如:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>http://192.168.1.1/ios.ipa</string> // 该地址为路由器本地地址
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>ddys</string>
<key>bundle-version</key>
<string>1.0</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>苹果app</string>
</dict>
</dict>
</array>
</dict>
</plist>
plist文件请求格式:
<a href="itms-services://?action=download-manifest&url=
https://duxiaotian.xyz/test.plist">下载苹果app </a>