Appengine - 使用https的本地开发服务器 [英] Appengine - Local dev server with https
问题描述
目标:
使用App Engine dev服务器减少开发 - 反馈周期。
我的使用必须以公共HTTPS地址提供。 App Engine dev服务器仅支持HTTP。
Goal: Reduce dev - feedback cycle by using App Engine dev server. For my use this must be available as a public HTTPS address. App Engine dev server only supports HTTP.
如何执行此操作:
使用ngrok将本地开发环境公开为https公共可用地址。
How to do this: Use ngrok to expose local dev environment as https publically available address.
从https到http的反向代理使用nginx。
Reverse proxy with nginx from https to http.
这似乎是可能的,但对我而言,没有配置工作。
This seems possible, but for life of me I haven't got the config working.
我在OSX上使用App Engine Standard Java。
I'm working with App Engine Standard Java on osx.
其他欢迎工作解决方案或想法。
Other working solutions or ideas are welcome. Surely there is a way to do this.
推荐答案
我使用NGINX作为自签名证书的代理服务于我的项目 https://debtstracker.io/
I use NGINX as proxy with self signed certificate for my project https://debtstracker.io/
这是我的NGINX配置。您还需要将一些 yourproject.local
记录添加到您的主机文件中。
Here is my NGINX config. You would also need to add some yourproject.local
record to your hosts file.
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 devserver,第二个用于Ionic项目。
The first location is for GAE devserver and 2nd for Ionic project.
以下是我用来生成证书的bash文件:
Here is a bash file I use to generate certificates:
#!/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/
希望这有帮助。花了我一段时间来设置它。
Hope this helps. Took me a while to set this up.
这篇关于Appengine - 使用https的本地开发服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!