{"id":655,"date":"2019-02-22T10:40:06","date_gmt":"2019-02-22T01:40:06","guid":{"rendered":"https:\/\/www.kwonline.org\/memo2\/?p=655"},"modified":"2020-06-18T08:51:18","modified_gmt":"2020-06-17T23:51:18","slug":"reverse-proxy-on-gae-standard-nodejs","status":"publish","type":"post","link":"https:\/\/www.kwonline.org\/memo2\/2019\/02\/22\/reverse-proxy-on-gae-standard-nodejs\/","title":{"rendered":"GAE Standard\u74b0\u5883\u306eNode.js\u3067\u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u69cb\u7bc9"},"content":{"rendered":"<p>\t\t\t\tSSL\u306e\u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u304c\u6b32\u3057\u304b\u3063\u305f\u306e\u3067\u30e1\u30e2<\/p>\n<p>HTTPS -> GAE (myproject.appspot.com) -> HTTP -> GCE (198.51.100.1:8080)<\/p>\n<p>\u3068\u3044\u3046\u69cb\u6210\u3002<\/p>\n<p>npm\u521d\u671f\u5316\u3057\u3066http\u3068http-proxy\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ npm init\r\n$ npm install http --save\r\n$ npm install http-proxy --save\r\n<\/pre>\n<p>\u3067\u3001\u4e0b\u8a18\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u610f<\/p>\n<p><strong>app.yaml<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nruntime: nodejs8\r\n<\/pre>\n<p><strong>index.js<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nconst http = require('http');\r\nconst httpProxy = require('http-proxy');\r\nconst port = process.env.PORT || 8080;\r\nhttpProxy.createProxyServer({target: 'http:\/\/198.51.100.1:8080\/'}).listen(port);\r\n<\/pre>\n<p><strong>package.json<\/strong><br \/>\npackage.json\u306fnpm init\u3067\u4f5c\u308b\u3068\u3057\u3066\u3001\u8d77\u52d5\u6642\u306bindex.js\u3092\u5b9f\u884c\u3057\u305f\u3044\u306e\u3067\u4e0b\u8a18\u306e\u3088\u3046\u306bscripts\u30d5\u30a3\u30fc\u30eb\u30c9\u5185\u3067index.js\u3092\u6307\u5b9a\u3059\u308b\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n  &quot;scripts&quot;: {\r\n    &quot;start&quot;: &quot;node index.js&quot;\r\n  },\r\n<\/pre>\n<p>\u3042\u3068\u306f\u3053\u308c\u3092AppEngine\u306b\u30c7\u30d7\u30ed\u30a4\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ gcloud app deploy\r\n<\/pre>\n<p>\u305d\u3057\u3066SSL\u3067 https:\/\/myproject.appspot.com\/ \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u30ea\u30af\u30a8\u30b9\u30c8\u304c http:\/\/198.51.100.1:8080\/ \u306b\u30d5\u30a9\u30ef\u30fc\u30c9\u3055\u308c\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SSL\u306e\u30ea\u30d0\u30fc\u30b9\u30d7\u30ed\u30ad\u30b7\u304c\u6b32\u3057\u304b\u3063\u305f\u306e\u3067\u30e1\u30e2 HTTPS -> GAE (myproject.appspot.com) -> HTTP -> GCE (198.51.100.1:8080) \u3068\u3044\u3046\u69cb\u6210\u3002 npm\u521d\u671f\u5316\u3057\u3066 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,8,17],"tags":[],"class_list":["post-655","post","type-post","status-publish","format-standard","hentry","category-javascript","category-linux","category-node-js"],"_links":{"self":[{"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/posts\/655","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/comments?post=655"}],"version-history":[{"count":1,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/posts\/655\/revisions"}],"predecessor-version":[{"id":1178,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/posts\/655\/revisions\/1178"}],"wp:attachment":[{"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/media?parent=655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/categories?post=655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/tags?post=655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}