【问题标题】:Appengine - Local dev server with httpsAppengine - 使用 https 的本地开发服务器
【发布时间】:2017-08-09 13:56:40
【问题描述】:

目标: 使用 App Engine 开发服务器减少开发 - 反馈周期。 对于我的使用,它必须可用作公共 HTTPS 地址。 App Engine 开发服务器仅支持 HTTP。

如何做到这一点: 使用 ngrok 将本地开发环境公开为 https 公开可用地址。

使用 nginx 从 https 到 http 的反向代理。

这似乎是可能的,但对于我来说,我的配置还没有工作。

我正在 osx 上使用 App Engine Standard Java。

欢迎其他可行的解决方案或想法。当然有办法做到这一点。

【问题讨论】:

  • 以下答案是否对您的请求有所帮助:启用您的 AppEngine 开发服务器与 HTTPS??
  • 顺便说一句,你可以看看之前关于这个的 SO 帖子:stackoverflow.com/questions/8849020/…

标签: google-app-engine nginx ngrok


【解决方案1】:

如果您只有一个模块需要通过 SSL 联系,您可以简单地使用这个https://github.com/cameronhunter/local-ssl-proxy。 安装和使用非常简单。 只需将目标端口更改为您的模块端口,然后通过 https 浏览到源端口即可。 如果您需要访问多个模块,则需要使用不同的参数(端口)多次运行它。

【讨论】:

    【解决方案2】:

    我使用 NGINX 作为代理,并为我的项目 https://debtstracker.io/ 提供自签名证书

    这是我的 NGINX 配置。您还需要在您的 hosts 文件中添加一些 yourproject.local 记录。

        server {  # This servers dynamic content of DebtsTracker.io project over HTTPS
                listen          443;
                server_name     debtstracker.local;
                ssl                  on;
                ssl_certificate      /etc/ssl/certs/debtstracker-local.crt;
                ssl_certificate_key  /etc/ssl/private/debtstracker-local.key;
    
                location /app/ {
                        proxy_pass   http://localhost:8100/;
                        proxy_set_header Host $http_host;
                }
    
                location / {
                        proxy_pass   http://127.0.0.1:8080;
                        proxy_set_header Host $http_host;
                }
        }
    

    第一个位置是 GAE 开发服务器,第二个位置是 Ionic 项目。

    这是我用来生成证书的 bash 文件:

    #!/usr/bin/env bash
    # https://www.accuweaver.com/2014/09/19/make-chrome-accept-a-self-signed-certificate-on-osx/
    
    # https://gist.github.com/jessedearing/2351836
    
    # Run using "sudo"
    
    echo "Generating an SSL private key to sign your certificate..."
    openssl genrsa -des3 -out debtstracker-local.key 1024
    
    echo "Generating a Certificate Signing Request..."
    openssl req -new -key debtstracker-local.key -out debtstracker-local.csr
    
    echo "Removing pass-phrase from key (for nginx)..."
    cp debtstracker-local.key debtstracker-local.key.org
    openssl rsa -in debtstracker-local.key.org -out debtstracker-local.key
    rm debtstracker-local.key.org
    
    echo "Generating certificate..."
    openssl x509 -req -days 365 -in debtstracker-local.csr -signkey debtstracker-local.key -out debtstracker-local.crt
    
    echo "Copying certificate (debtstracker-local.crt) to /etc/ssl/certs/"
    mkdir -p  /etc/ssl/certs
    cp debtstracker-local.crt /etc/ssl/certs/
    
    echo "Copying key (debtstracker-local.key) to /etc/ssl/private/"
    mkdir -p  /etc/ssl/private
    cp debtstracker-local.key /etc/ssl/private/
    

    希望这会有所帮助。我花了一些时间来设置它。

    【讨论】:

    • 这完全适合我。现在我可以使用本地开发服务器作为公共网址,而无需在开发时支付实例时间。也比部署更快。现在,如果我们只是有类似即时运行的东西,那么我们真的会做饭。假设 JRebel 可以工作
    • Instant run 是一款 Android 开发工具,可在运行的应用程序中逐步更新 Java 代码更改。为 appengine 提供类似的东西会很棒
    【解决方案3】:

    ngrok 支持任何 http 端口的 https url,因此您可以使用 ngrok 将 https 域代理到 GAE 开发服务器端口

    如果您有付费帐户,则可以设置 CNAME 以使用您自己的域

    ngrok http -hostname=dev.example.com 8080
    

    【讨论】:

      猜你喜欢
      • 2019-01-11
      • 1970-01-01
      • 2014-10-01
      • 2017-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多