From cc309084b2dd8b9780e7175851990742f9712926 Mon Sep 17 00:00:00 2001 From: tinyc Date: Thu, 24 Jun 2021 17:23:30 +0800 Subject: [PATCH] update nginx confix to fix https 422 error --- Gemfile.lock | 4 +++- README.md | 31 +++++++++++++++++++++++++++++-- docker/launcher | 2 +- docker/nginx.conf | 2 +- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1382774..d8be446 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -122,7 +122,9 @@ GEM marcel (0.3.3) mimemagic (~> 0.3.2) method_source (1.0.0) - mimemagic (0.3.5) + mimemagic (0.3.10) + nokogiri (~> 1) + rake mini_magick (4.11.0) mini_mime (1.0.2) mini_portile2 (2.5.0) diff --git a/README.md b/README.md index 06c7935..45ac4b9 100644 --- a/README.md +++ b/README.md @@ -47,11 +47,38 @@ ps:数据库和上传的文件会保存在 ./shared 文件夹中 ``` ## 关于 https -1. https其实不属于本项目涉及的范畴,大家可以 google 一下 https 证书配置,挂 nginx 或者 apache 上都行,有条件的可以购买域名证书,没条件的自签名证书也是可以的 +如果需要用到ipa下载,必须配置 https,举例 ng 的配置参考 +``` +//https_app.conf +server { + listen 443 ssl; + server_name ota.xxx.com; + + # access_log /var/log/nginx/ota.xxx.com_access.log; + + ssl_certificate /home/xxx.com/nginx/public.pem; + ssl_certificate_key /home/xxx.com/nginx/private.key; + ssl on; + + location / { + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + proxy_pass http://172.21.35.62:3000; #此处改为 docker 服务的地址 + } +} + +server { + listen 80; + server_name ota.xxx.com; + rewrite ^(.*)$ https://$host$1 permanent; +} +``` ## 已知问题 1. apk 包如果是非图片 logo,会无法显示 logo,因为目前还没实现 xml logo 的解析 -2. 如果不配置 https,ipa 将无法安装 +2. 如果不配置 https,ipa 将无法安装(苹果的限制) ## License diff --git a/docker/launcher b/docker/launcher index c28c482..cc0067d 100755 --- a/docker/launcher +++ b/docker/launcher @@ -21,7 +21,7 @@ usage () { set -e set -o pipefail -version=0.2.0 +version=0.2.1 local_port=3000 local_image=local_pluosi/app_host:$version container_name=app_host diff --git a/docker/nginx.conf b/docker/nginx.conf index 62f1a23..cc641a0 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -26,7 +26,7 @@ server { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; proxy_set_header X-Forwarded-Port $server_port; if (!-f $request_filename) {