第一 先安装nginx
第二 修改nginx配置
# vim /usr/local/nginx/conf/nginx.conf
#配置用户和用户组
#user nobody;
#工作进程数,建议设置为CPU的总核数
worker_processes 4;
#全局错误日志定义类型,日志等级从低到高依次为: debug | info | notice | warn | error | crit
#error_log logs/error.log;
#error_log logs/error.log notice;
error_log logs/error.log info;
#记录主进程ID的文件
#pid logs/nginx.pid;
#工作模式与连接数上限
events {
#单个进程允许的最大连接数
worker_connections 1024;
}
#设定http服务器,利用它的反向代理功能提供负载均衡支持
http {
#文件扩展名与文件类型映射表
include mime.types;
#默认文件类型
default_type application/octet-stream;
#日志格式
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access log 记录了哪些用户,哪些页面以及用户浏览器、ip和其他的访问信息
access_log logs/access.log main;
#开启文件传输,一般应用都应设置为on;若是有下载的应用,则可以设置成off来平衡网络I/O和磁盘的I/O来降低系统负载
sendfile on;
#告诉nginx在一个数据包里发送所有头文件,而不一个接一个的发送。
#tcp_nopush on;
#长连接超时时间,单位是秒
#keepalive_timeout 0;
keepalive_timeout 65;
### gzip模块设置,使用 gzip 压缩可以降低网站带宽消耗,同时提升访问速度。
gzip on; #开启gzip
gzip_min_length 1k; #最小压缩大小
gzip_buffers 4 16k; #压缩缓冲区
gzip_http_version 1.0; #压缩版本
gzip_comp_level 2; #压缩等级
gzip_types text/plain application/x-javascript text/css application/xml; #压缩类型
### gzip 模块 end
#一台服务器挂了,自动去找另一台服务器,这要使用到proxy_pass
#注意:upstream中的server元素必须要注意,不能加http://,但proxy_pass中必须加
#upstream toms{
# server 47.92.163.127:8080;
#}
#server 配置 begin,可以配置多个
# 包含所有的虚拟主机的配置文件
# include conf/mhost/*;
server_tokens off;
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
server{
listen 80;
server_name www.xxx.com;
limit_req zone=one burst=5; #最多等待5个请求,多余的拒接
access_log logs/indexaccess.log main;
error_log logs/indexerror.log;
if ($request_method !~ ^(GET|POST)$ ) {
return 444;
}
location / {
# proxy_pass http://toms;
root /usr/local/html/dist/static/index/pc/;
if ( $http_user_agent ~ "(MIDP)|(WAP)|(UP.Browser)|(Smartphone)|(Obigo)|(Mobile)|(AU.Browser)|(wxd.Mms)|(WxdB.Browser)|(CLDC)|(UP.Link)|(KM.Browser)|(UCWEB)|(SEMC-Browser)|(Mini)|(Symbian)|(Palm)|(Nokia)|(Panasonic)|(MOT-)|(SonyEricsson)|(NEC-)|(Alcatel)|(Ericsson)|(BENQ)|(BenQ)|(Amoisonic)|(Amoi-)|(Capitel)|(PHILIPS)|(SAMSUNG)|(Lenovo)|(Mitsu)|(Motorola)|(SHARP)|(WAPPER)|(LG-)|(LG/)|(EG900)|(CECT)|(Compal)|(kejian)|(Bird)|(BIRD)|(G900/V1.0)|(Arima)|(CTL)|(TDG)|(Daxian)|(DAXIAN)|(DBTEL)|(Eastcom)|(EASTCOM)|(PANTECH)|(Dopod)|(Haier)|(HAIER)|(KONKA)|(KEJIAN)|(LENOVO)|(Soutec)|(SOUTEC)|(SAGEM)|(SEC-)|(SED-)|(EMOL-)|(INNO55)|(ZTE)|(iPhone)|(Android)|(Windows CE)|(Wget)|(Java)|(curl)|(Opera)" )
{
root /usr/local/html/dist/static/index/mobile/;
}
index index.html index.htm;
}
}
server{
#admin静态页面
listen 80;
server_name admin.abc.xxx.com;
access_log logs/frontaccess.log main;
error_log logs/fronterror.log;
location ~ \.(html|js|css|png|jpg|gif|woff|woff2|ttf|apk|ipa)$ {
root /usr/local/html/dist/;
index index.html index.htm;
}
location ^~ /api/
{
proxy_pass http://127.0.0.1:10001/;
}
}
server {
listen 80;
server_name back.xxxxx.com;
access_log logs/backaccess.log main;
error_log logs/backerror.log;
location / {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:10001;
}
}
}
# pwd
/usr/local/html/dist
[root@ycz dist]# ls
caizhan99_android.apk favicon.ico xy729_?û?_Sh.ipa_1.1.1.ipa
caizhan99_ios.ipa index.html
cpw.plist #IOS安装清单 static
第三 移动端的访问首页文件(index.html)
# pwd
/usr/local/html/dist/static/index/mobile
# vim index.html
<!--
* @Descripttion:
* @version:
* @Author: falost
* @LastEditors: falost
* @Date: 2019-06-01 10:42:11
* @LastEditTime: 2019-06-01 11:48:15
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="renderer" content="webkit">
<meta name="Author" content="观极、Leien">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>99keji下载</title>
<style>
.bg_img {
background: url("./bgImg.jpg") no-repeat center;
background-size: contain;
width: 100%;
height: 100%;
position: relative;
}
body,html{
margin:0;
padding:0;
height:100%;
}
.download_btn{
position: relative;
left: 50%;
top: 85%;
width: 150px;
text-align: center;
padding: 10px 15px;
transform: translate(-50%, -50%);
border-radius: 5px;
margin-top: 5px;
color: #fff;
background: -webkit-linear-gradient(left top,#dbdcde , #1f3300);
}
.beian{
position: absolute;
bottom:15px;
left:50%;
transform: translateX(-50%) translateY(-50%);
color:#fff;
font-size:12px;
}
</style>
</head>
<body>
<div class="bg_img">
<div class="download_btn" onclick="toDownload()">
点击下载
</div>
<div class="beian">陕ICP备190xxxx号-1</div>
</div>
</body>
<script>
// toDownload();
// 新的方法
function toDownload(){
console.log("ddd");
console.log(IsPC());
var u = navigator.userAgent;
var ua = u.toLowerCase();
if (/iphone|ipad|ipod/.test(ua)) { // iOS 系统 -> 跳AppStore下载地址
//alert("iOS");
window.location.href = 'itms-services://?action=download-manifest&url=https://www.falost.cc/public/cpw.plist'; //必须用https协议访问cpw.plist安装清单--->IOS签名的 ,可以搭建一个ftp服务器放在下面,也可以在本服务器上放置.plist文件
} else if ( /android/.test(ua)) { // 安卓系统 -> 跳安卓端下载地址
console.log("ssss");
window.location.href = 'http://admin.abc.caizhan99.com/caizhan99_android.apk';
//alert("android");
} else if (IsPC()){ // PC端
window.location.href = 'http://admin.abc.caizhan99.com/caizhan99_android.apk';
}
}
function IsPC() {
if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
return false;
}else {
return true;
}
}
</script>
</html>
写IOS 的安装清单文件 cpw.plist
<?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://admin.abc.caizhan99.com/caizhan99_ios.ipa</string>
</dict>
<dict>
<key>kind</key>
<string>full-size-image</string>
<key>needs-shine</key>
<true/>
<key>url</key>
<string>http://admin.abc.caizhan99.com/logo.png</string>
</dict>
<dict>
<key>kind</key>
<string>display-image</string>
<key>needs-shine</key>
<true/>
<key>url</key>
<string>http://admin.abc.caizhan99.com/logo.png</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>com.app.cpw</string>
<key>bundle-version</key>
<string>1.1.0</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>好货</string>
</dict>
</dict>
</array>
</dict>
</plist>
下载安装包放置路径 : http://admin.abc.caizhan99.com/caizhan99_ios.ipa
IOS 清单文件放置路径: https://www.xxx.cc/public/cpw.plis
第四 生成访问二维码:
第五 访问测试
1, 用微信打开 ,不要用 Safari浏览器打开:
2, 信任安装:
完工:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++