├── .gitignore ├── LICENSE ├── README.md ├── config.yml.default ├── handler.js ├── package-lock.json ├── package.json └── serverless.yml /.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | # Serverless directories 6 | .serverless 7 | 8 | # app config 9 | config.yml 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | https://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of yright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | Copyright 2015-2017, Erica Windisch. IOpipe, Inc. 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | https://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. 192 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Serverless reverse proxy 2 | 3 | Provides a reverse proxy into VPC resources on AWS. Can optionally sign requests 4 | by setting the `AWS_SIGN_REQUESTS` environment variable. 5 | 6 | ## Installation 7 | 8 | Edit `config.yml` and edit the URL variable to point to your backend 9 | URL. Optionally set `AWS_SIGN_REQUESTS` if requests should be signed to the 10 | backend services. 11 | 12 | Run `sls deploy`. 13 | 14 | 15 | ## Requirements 16 | 17 | * Serverless Framework 1.0+ 18 | * NodeJS 19 | 20 | ## License 21 | 22 | Apache-2.0 see LICENSE 23 | -------------------------------------------------------------------------------- /config.yml.default: -------------------------------------------------------------------------------- 1 | URL: https://example.com 2 | #AWS_SIGN_REQUESTS: true 3 | #IOPIPE_TOKEN: 4 | -------------------------------------------------------------------------------- /handler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const http = require('http') 3 | const url = require('url') 4 | const ioProfiler = require('lambda-profiler')({}) 5 | 6 | var signRequest = (requestOptions) => { return requestOptions } 7 | if (process.env.AWS_SIGN_REQUESTS) { 8 | signRequest = require('aws4').sign 9 | } 10 | 11 | var profiler = (func) => { return func } 12 | if (process.env.TRACE_REQUESTS) { 13 | profiler = ioProfiler 14 | } 15 | 16 | const httpAgent = http.Agent({ 17 | keepAlive: true, 18 | keepAliveMsecs: 300000 19 | }) 20 | 21 | module.exports.proxy = profiler((event, context, callback) => { 22 | var res = http.request(signRequest({ 23 | hostname: process.env.URL, 24 | method: event.httpMethod, 25 | headers: event.headers, 26 | path: event.path, 27 | agent: httpAgent, 28 | timeout: 30 /* maximum time for api gateway invoked Lambda */ 29 | })) 30 | 31 | var resBody = "" 32 | res.on('data', (chunk) => { 33 | resBody += chunk 34 | }) 35 | .on('end', () => { 36 | var response = { 37 | statusCode: res.statusCode, 38 | headers: res.headers, 39 | body: resBody 40 | } 41 | console.log(response) 42 | callback(null, response) 43 | }) 44 | }) 45 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "awslambda-reverse-proxy", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "dependencies": { 6 | "ajv": { 7 | "version": "4.11.8", 8 | "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", 9 | "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=" 10 | }, 11 | "asn1": { 12 | "version": "0.2.3", 13 | "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", 14 | "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" 15 | }, 16 | "assert-plus": { 17 | "version": "0.2.0", 18 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", 19 | "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=" 20 | }, 21 | "async": { 22 | "version": "1.2.1", 23 | "resolved": "https://registry.npmjs.org/async/-/async-1.2.1.tgz", 24 | "integrity": "sha1-pIFqF81f9RbfosdpikUzabl5DeA=" 25 | }, 26 | "asynckit": { 27 | "version": "0.4.0", 28 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 29 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" 30 | }, 31 | "aws-sign2": { 32 | "version": "0.6.0", 33 | "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", 34 | "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=" 35 | }, 36 | "aws4": { 37 | "version": "1.6.0", 38 | "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", 39 | "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" 40 | }, 41 | "bcrypt-pbkdf": { 42 | "version": "1.0.1", 43 | "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", 44 | "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", 45 | "optional": true 46 | }, 47 | "boom": { 48 | "version": "2.10.1", 49 | "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", 50 | "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=" 51 | }, 52 | "caseless": { 53 | "version": "0.12.0", 54 | "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", 55 | "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" 56 | }, 57 | "co": { 58 | "version": "4.6.0", 59 | "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", 60 | "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" 61 | }, 62 | "combined-stream": { 63 | "version": "1.0.5", 64 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", 65 | "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=" 66 | }, 67 | "cryptiles": { 68 | "version": "2.0.5", 69 | "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", 70 | "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=" 71 | }, 72 | "dashdash": { 73 | "version": "1.14.1", 74 | "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", 75 | "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", 76 | "dependencies": { 77 | "assert-plus": { 78 | "version": "1.0.0", 79 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", 80 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" 81 | } 82 | } 83 | }, 84 | "debug": { 85 | "version": "2.6.7", 86 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.7.tgz", 87 | "integrity": "sha1-krrR9tBbu2u6Isyoi80OyJTChh4=" 88 | }, 89 | "delayed-stream": { 90 | "version": "1.0.0", 91 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 92 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" 93 | }, 94 | "ecc-jsbn": { 95 | "version": "0.1.1", 96 | "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", 97 | "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", 98 | "optional": true 99 | }, 100 | "extend": { 101 | "version": "3.0.1", 102 | "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", 103 | "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" 104 | }, 105 | "extsprintf": { 106 | "version": "1.0.2", 107 | "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", 108 | "integrity": "sha1-4QgOBljjALBilJkMxw4VAiNf1VA=" 109 | }, 110 | "forever-agent": { 111 | "version": "0.6.1", 112 | "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", 113 | "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" 114 | }, 115 | "form-data": { 116 | "version": "2.1.4", 117 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", 118 | "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=" 119 | }, 120 | "fs-extra": { 121 | "version": "2.1.2", 122 | "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-2.1.2.tgz", 123 | "integrity": "sha1-BGxwFjzvmq1GsOSn+kZ/si1x3jU=" 124 | }, 125 | "getpass": { 126 | "version": "0.1.7", 127 | "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", 128 | "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", 129 | "dependencies": { 130 | "assert-plus": { 131 | "version": "1.0.0", 132 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", 133 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" 134 | } 135 | } 136 | }, 137 | "graceful-fs": { 138 | "version": "4.1.11", 139 | "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", 140 | "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" 141 | }, 142 | "har-schema": { 143 | "version": "1.0.5", 144 | "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", 145 | "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=" 146 | }, 147 | "har-validator": { 148 | "version": "4.2.1", 149 | "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", 150 | "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=" 151 | }, 152 | "hawk": { 153 | "version": "3.1.3", 154 | "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", 155 | "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=" 156 | }, 157 | "hoek": { 158 | "version": "2.16.3", 159 | "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", 160 | "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=" 161 | }, 162 | "http-signature": { 163 | "version": "1.1.1", 164 | "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", 165 | "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=" 166 | }, 167 | "is-typedarray": { 168 | "version": "1.0.0", 169 | "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", 170 | "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" 171 | }, 172 | "isstream": { 173 | "version": "0.1.2", 174 | "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", 175 | "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" 176 | }, 177 | "jsbn": { 178 | "version": "0.1.1", 179 | "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", 180 | "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", 181 | "optional": true 182 | }, 183 | "json-schema": { 184 | "version": "0.2.3", 185 | "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", 186 | "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" 187 | }, 188 | "json-stable-stringify": { 189 | "version": "1.0.1", 190 | "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", 191 | "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=" 192 | }, 193 | "json-stringify-safe": { 194 | "version": "5.0.1", 195 | "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", 196 | "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" 197 | }, 198 | "jsonfile": { 199 | "version": "2.4.0", 200 | "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", 201 | "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=" 202 | }, 203 | "jsonify": { 204 | "version": "0.0.0", 205 | "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", 206 | "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=" 207 | }, 208 | "jsprim": { 209 | "version": "1.4.0", 210 | "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", 211 | "integrity": "sha1-o7h+QCmNjDgFUtjMdiigu5WiKRg=", 212 | "dependencies": { 213 | "assert-plus": { 214 | "version": "1.0.0", 215 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", 216 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" 217 | } 218 | } 219 | }, 220 | "lodash": { 221 | "version": "4.17.4", 222 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", 223 | "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" 224 | }, 225 | "mime-db": { 226 | "version": "1.27.0", 227 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", 228 | "integrity": "sha1-gg9XIpa70g7CXtVeW13oaeVDbrE=" 229 | }, 230 | "mime-types": { 231 | "version": "2.1.15", 232 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", 233 | "integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=" 234 | }, 235 | "ms": { 236 | "version": "2.0.0", 237 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 238 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 239 | }, 240 | "oauth-sign": { 241 | "version": "0.8.2", 242 | "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", 243 | "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" 244 | }, 245 | "performance-now": { 246 | "version": "0.2.0", 247 | "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", 248 | "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=" 249 | }, 250 | "punycode": { 251 | "version": "1.4.1", 252 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", 253 | "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" 254 | }, 255 | "qs": { 256 | "version": "6.4.0", 257 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", 258 | "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=" 259 | }, 260 | "request": { 261 | "version": "2.81.0", 262 | "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", 263 | "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=" 264 | }, 265 | "safe-buffer": { 266 | "version": "5.1.0", 267 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.0.tgz", 268 | "integrity": "sha512-aSLEDudu6OoRr/2rU609gRmnYboRLxgDG1z9o2Q0os7236FwvcqIOO8r8U5JUEwivZOhDaKlFO4SbPTJYyBEyQ==" 269 | }, 270 | "serverless-plugin-iopipe": { 271 | "version": "0.2.1", 272 | "resolved": "https://registry.npmjs.org/serverless-plugin-iopipe/-/serverless-plugin-iopipe-0.2.1.tgz", 273 | "integrity": "sha1-Ec7+O0YI0gL19Ecgugiy2Kpx1kE=" 274 | }, 275 | "sntp": { 276 | "version": "1.0.9", 277 | "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", 278 | "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=" 279 | }, 280 | "sshpk": { 281 | "version": "1.13.1", 282 | "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", 283 | "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", 284 | "dependencies": { 285 | "assert-plus": { 286 | "version": "1.0.0", 287 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", 288 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" 289 | } 290 | } 291 | }, 292 | "stringstream": { 293 | "version": "0.0.5", 294 | "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", 295 | "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=" 296 | }, 297 | "tough-cookie": { 298 | "version": "2.3.2", 299 | "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", 300 | "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=" 301 | }, 302 | "tunnel-agent": { 303 | "version": "0.6.0", 304 | "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", 305 | "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=" 306 | }, 307 | "tweetnacl": { 308 | "version": "0.14.5", 309 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", 310 | "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", 311 | "optional": true 312 | }, 313 | "underscore": { 314 | "version": "1.8.3", 315 | "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", 316 | "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=" 317 | }, 318 | "universal-analytics": { 319 | "version": "0.4.13", 320 | "resolved": "https://registry.npmjs.org/universal-analytics/-/universal-analytics-0.4.13.tgz", 321 | "integrity": "sha1-3Ggp/3KXrhtPjRQn1alFUh8buiY=" 322 | }, 323 | "uuid": { 324 | "version": "3.0.1", 325 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz", 326 | "integrity": "sha1-ZUS7ot/ajBzxfmKaOjBeK7H+5sE=" 327 | }, 328 | "verror": { 329 | "version": "1.3.6", 330 | "resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", 331 | "integrity": "sha1-z/XfEpRtKX0rqu+qJoniW+AcAFw=" 332 | } 333 | } 334 | } 335 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "awslambda-reverse-proxy", 3 | "version": "1.0.0", 4 | "description": "Serverless Reverse Proxy for AWS", 5 | "main": "lambda.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Erica Windisch ", 10 | "license": "Apache-2.0", 11 | "dependencies": { 12 | "aws4": "^1.6.0", 13 | "iopipe": "^0.5.0", 14 | "serverless-plugin-iopipe": "^0.2.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /serverless.yml: -------------------------------------------------------------------------------- 1 | # For full config options, check the docs: 2 | # docs.serverless.com 3 | 4 | service: awslambda-rproxy 5 | 6 | # You can pin your service to only deploy with a specific Serverless version 7 | # Check out our docs for more details 8 | # frameworkVersion: "=X.X.X" 9 | 10 | provider: 11 | name: aws 12 | runtime: nodejs6.10 13 | region: us-west-1 14 | 15 | plugins: 16 | - serverless-plugin-iopipe 17 | custom: 18 | iopipeToken: ${file(./config.yml):IOPIPE_TOKEN} 19 | 20 | functions: 21 | proxy: 22 | handler: handler.proxy 23 | events: 24 | - http: 25 | path: / 26 | method: any 27 | environment: 28 | URL: ${file(./config.yml):URL} 29 | AWS_SIGN_REQUESTS: ${file(./config.yml):AWS_SIGN_REQUESTS} 30 | --------------------------------------------------------------------------------