Skip to content

Commit a2d9d17

Browse files
committed
Folder restructure
Remove redundancies Update README.md and docs
1 parent 0dcee65 commit a2d9d17

25 files changed

+873
-603
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Vignesh Sivanandha Rao
3+
Copyright (c) 2021 Vignesh Rao
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+16-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Expose localhost using EC2
2-
Expose an app/api running on local host to public internet using AWS EC2
2+
Reverse proxy that creates a secure tunnel from public endpoint to locally running web service
33

44
### Requirements
55
- Access to an AWS account and [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions) configured.
@@ -29,7 +29,7 @@ The public DNS names for EC2 instances are long and messy. To avoid that, an `A`
2929

3030
:warning:   Requires an active hosted zone on `route53`.
3131

32-
- **DOMAIN**: Domain name registered using `route53`. *Example: `mywebsite.com`*
32+
- **HOSTED_ZONE**: Hosted zone name registered using `route53`. *Example: `mywebsite.com`*
3333
- **SUBDOMAIN**: Sub-domain that has to be added for the domain name. *Example: `tunnel`*
3434

3535
        :bulb:   `tunnel.mywebsite.com` will be the endpoint to access the localhost from public internet.
@@ -47,17 +47,17 @@ The public DNS names for EC2 instances are long and messy. To avoid that, an `A`
4747

4848
:warning:   Some web browsers might throw a warning and some might even block a self-signed certificate/private CA.
4949

50-
To manually generate a self-signed cert:
51-
52-
> `openssl req -newkey rsa:2048 -sha256 -nodes -keyout YOURPRIVATE.key -x509 -days 365 -out YOURPUBLIC.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=YOURDOMAIN.EXAMPLE"`
53-
54-
[OR]
55-
56-
Simply let `expose` create a self-signed SSL certificate and a private key. **(Default behavior)**
50+
`expose` creates a self-signed SSL certificate and a private key by default.
5751

5852
- **EMAIL_ADDRESS**: Email address to create the self-signed SSL and private key. Defaults to `[email protected]`
5953
- **ORGANIZATION**: Organization name for the certificate. Defaults to the AWS endpoint.
6054

55+
**Manually generate self-signed certificate**
56+
> `openssl req -newkey rsa:2048 -sha256 -nodes -keyout private.pem -x509 -days 365 -out public.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=tunnel.example.com"`
57+
58+
**To verify the generated certificate**
59+
> `openssl x509 -inform pem -in public.pem -noout -text`
60+
6161
</details>
6262

6363
### Usage
@@ -80,11 +80,9 @@ tunnel = expose.Tunnel()
8080
# Start tunneling
8181
tunnel.start()
8282

83-
# set 'purge' flag to 'True' to delete AWS resources if configuration fails
83+
# set 'purge' flag to 'True' to reclaim AWS resources if configuration fails
8484
# tunnel.start(purge=True)
8585

86-
# sleep or do something else
87-
8886
# Stop tunneling - deletes all AWS resources acquired
8987
tunnel.stop()
9088
```
@@ -100,11 +98,11 @@ tunnel.stop()
10098
### Limitations
10199
Currently `expose` cannot handle, tunneling multiple port numbers without modifying the following env vars in the `.env` file.
102100
```shell
103-
KEY_PAIR
104-
SECURITY_GROUP
105-
KEY_FILE
106-
CERT_FILE
107-
SERVER_INFO
101+
KEY_PAIR # SSH connection to AWS ec2
102+
KEY_FILE # Private key filename for self signed SSL
103+
CERT_FILE # Public certificate filename for self signed SSL
104+
SERVER_INFO # Filename to dump JSON data with server configuration information
105+
SECURITY_GROUP # Ingress and egress firewall rules to control traffic allowed via VPC
108106
```
109107

110108
## Coding Standards
@@ -149,6 +147,6 @@ pre-commit run --all-files
149147

150148
## License & copyright
151149

152-
&copy; Vignesh Sivanandha Rao
150+
&copy; Vignesh Rao
153151

154152
Licensed under the [MIT License](https://github.com/thevickypedia/expose/blob/main/LICENSE)

doc_gen/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
# -- Project information -----------------------------------------------------
1919

2020
project = 'Expose'
21-
copyright = '2021, Vignesh Sivanandha Rao'
22-
author = 'Vignesh Sivanandha Rao'
21+
copyright = '2021, Vignesh Rao'
22+
author = 'Vignesh Rao'
2323

2424
# -- General configuration ---------------------------------------------------
2525

doc_gen/index.rst

+39-21
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
55
6-
Welcome to Expose's documentation!
7-
==================================
6+
Expose - Expose a web service on localhost to public internet using AWS EC2
7+
===========================================================================
88

99
.. toctree::
1010
:maxdepth: 2
@@ -19,46 +19,64 @@ Expose - Main Module
1919
:members:
2020
:undoc-members:
2121

22-
Expose - Configuration
23-
======================
22+
Expose - Auxiliary
23+
==================
2424

25-
.. automodule:: expose.helpers.server
25+
.. automodule:: expose.models.auxiliary
2626
:members:
2727
:undoc-members:
2828

29-
Expose - Route53
30-
================
29+
Expose - Certificates
30+
=====================
3131

32-
.. automodule:: expose.helpers.route_53
32+
.. automodule:: expose.models.cert
3333
:members:
3434
:undoc-members:
3535

36-
Expose - Auxiliary
37-
==================
36+
Expose - Configuration
37+
======================
3838

39-
.. automodule:: expose.helpers.auxiliary
39+
.. autoclass:: expose.models.config.AWSDefaults(pydantic.BaseModel)
4040
:members:
41-
:undoc-members:
41+
:exclude-members: _abc_impl, model_config, model_fields
4242

43-
Expose - Certificates
44-
=====================
43+
====
4544

46-
.. automodule:: expose.helpers.cert
45+
.. autoclass:: expose.models.config.EnvConfig(pydantic_settings.BaseSettings)
4746
:members:
48-
:undoc-members:
47+
:exclude-members: _abc_impl, model_config, model_fields
4948

50-
Expose - AWS Defaults
51-
=====================
49+
====
50+
51+
.. autoclass:: expose.models.config.Settings(pydantic.BaseModel)
52+
:members:
53+
:exclude-members: _abc_impl, model_config, model_fields
5254

53-
.. automodule:: expose.helpers.defaults
55+
Expose - Exceptions
56+
===================
57+
58+
.. automodule:: expose.models.exceptions
5459
:members:
5560
:undoc-members:
56-
:exclude-members: DEFAULT_AMI_NAME, IMAGE_MAP
5761

5862
Expose - LOGGER
5963
===============
6064

61-
.. automodule:: expose.helpers.logger
65+
.. automodule:: expose.models.logger
66+
:members:
67+
:undoc-members:
68+
69+
Expose - Route53
70+
================
71+
72+
.. automodule:: expose.models.route_53
73+
:members:
74+
:undoc-members:
75+
76+
Expose - Server Configuration
77+
=============================
78+
79+
.. automodule:: expose.models.server
6280
:members:
6381
:undoc-members:
6482

docs/README.html

+23-22
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<link rel="index" title="Index" href="genindex.html" />
2020
<link rel="search" title="Search" href="search.html" />
21-
<link rel="prev" title="Welcome to Expose’s documentation!" href="index.html" />
21+
<link rel="prev" title="Expose - Expose a web service on localhost to public internet using AWS EC2" href="index.html" />
2222
</head><body>
2323
<div class="related" role="navigation" aria-label="related navigation">
2424
<h3>Navigation</h3>
@@ -30,7 +30,7 @@ <h3>Navigation</h3>
3030
<a href="py-modindex.html" title="Python Module Index"
3131
>modules</a> |</li>
3232
<li class="right" >
33-
<a href="index.html" title="Welcome to Expose’s documentation!"
33+
<a href="index.html" title="Expose - Expose a web service on localhost to public internet using AWS EC2"
3434
accesskey="P">previous</a> |</li>
3535
<li class="nav-item nav-item-0"><a href="index.html">Expose documentation</a> &#187;</li>
3636
<li class="nav-item nav-item-this"><a href="">Expose localhost using EC2</a></li>
@@ -44,7 +44,7 @@ <h3>Navigation</h3>
4444

4545
<section id="expose-localhost-using-ec2">
4646
<h1>Expose localhost using EC2<a class="headerlink" href="#expose-localhost-using-ec2" title="Permalink to this heading"></a></h1>
47-
<p>Expose an app/api running on local host to public internet using AWS EC2</p>
47+
<p>Reverse proxy that creates a secure tunnel from public endpoint to locally running web service</p>
4848
<section id="requirements">
4949
<h2>Requirements<a class="headerlink" href="#requirements" title="Permalink to this heading"></a></h2>
5050
<ul class="simple">
@@ -76,7 +76,7 @@ <h3>Environment Variables:<a class="headerlink" href="#environment-variables" ti
7676
<summary><strong>Setup a custom endpoint</strong></summary><p>The public DNS names for EC2 instances are long and messy. To avoid that, an <code class="docutils literal notranslate"><span class="pre">A</span></code> record can be added to the <code class="docutils literal notranslate"><span class="pre">route53</span></code> hosted zone.</p>
7777
<p>:warning:   Requires an active hosted zone on <code class="docutils literal notranslate"><span class="pre">route53</span></code>.</p>
7878
<ul class="simple">
79-
<li><p><strong>DOMAIN</strong>: Domain name registered using <code class="docutils literal notranslate"><span class="pre">route53</span></code>. <em>Example: <code class="docutils literal notranslate"><span class="pre">mywebsite.com</span></code></em></p></li>
79+
<li><p><strong>HOSTED_ZONE</strong>: Hosted zone name registered using <code class="docutils literal notranslate"><span class="pre">route53</span></code>. <em>Example: <code class="docutils literal notranslate"><span class="pre">mywebsite.com</span></code></em></p></li>
8080
<li><p><strong>SUBDOMAIN</strong>: Sub-domain that has to be added for the domain name. <em>Example: <code class="docutils literal notranslate"><span class="pre">tunnel</span></code></em></p></li>
8181
</ul>
8282
<p>        :bulb:   <code class="docutils literal notranslate"><span class="pre">tunnel.mywebsite.com</span></code> will be the endpoint to access the localhost from public internet.</p>
@@ -91,16 +91,19 @@ <h3>Certificate:<a class="headerlink" href="#certificate" title="Permalink to th
9191
</ul>
9292
<details>
9393
<summary><strong>Generate self-signed SSL certificate</strong></summary><p>:warning:   Some web browsers might throw a warning and some might even block a self-signed certificate/private CA.</p>
94-
<p>To manually generate a self-signed cert:</p>
95-
<blockquote>
96-
<div><p><code class="docutils literal notranslate"><span class="pre">openssl</span> <span class="pre">req</span> <span class="pre">-newkey</span> <span class="pre">rsa:2048</span> <span class="pre">-sha256</span> <span class="pre">-nodes</span> <span class="pre">-keyout</span> <span class="pre">YOURPRIVATE.key</span> <span class="pre">-x509</span> <span class="pre">-days</span> <span class="pre">365</span> <span class="pre">-out</span> <span class="pre">YOURPUBLIC.pem</span> <span class="pre">-subj</span> <span class="pre">&quot;/C=US/ST=New</span> <span class="pre">York/L=Brooklyn/O=Example</span> <span class="pre">Brooklyn</span> <span class="pre">Company/CN=YOURDOMAIN.EXAMPLE&quot;</span></code></p>
97-
</div></blockquote>
98-
<p>[OR]</p>
99-
<p>Simply let <code class="docutils literal notranslate"><span class="pre">expose</span></code> create a self-signed SSL certificate and a private key. <strong>(Default behavior)</strong></p>
94+
<p><code class="docutils literal notranslate"><span class="pre">expose</span></code> creates a self-signed SSL certificate and a private key by default.</p>
10095
<ul class="simple">
10196
<li><p><strong>EMAIL_ADDRESS</strong>: Email address to create the self-signed SSL and private key. Defaults to <code class="docutils literal notranslate"><span class="pre">USER&#64;expose-localhost.com</span></code></p></li>
10297
<li><p><strong>ORGANIZATION</strong>: Organization name for the certificate. Defaults to the AWS endpoint.</p></li>
10398
</ul>
99+
<p><strong>Manually generate self-signed certificate</strong></p>
100+
<blockquote>
101+
<div><p><code class="docutils literal notranslate"><span class="pre">openssl</span> <span class="pre">req</span> <span class="pre">-newkey</span> <span class="pre">rsa:2048</span> <span class="pre">-sha256</span> <span class="pre">-nodes</span> <span class="pre">-keyout</span> <span class="pre">private.pem</span> <span class="pre">-x509</span> <span class="pre">-days</span> <span class="pre">365</span> <span class="pre">-out</span> <span class="pre">public.pem</span> <span class="pre">-subj</span> <span class="pre">&quot;/C=US/ST=New</span> <span class="pre">York/L=Brooklyn/O=Example</span> <span class="pre">Brooklyn</span> <span class="pre">Company/CN=tunnel.example.com&quot;</span></code></p>
102+
</div></blockquote>
103+
<p><strong>To verify the generated certificate</strong></p>
104+
<blockquote>
105+
<div><p><code class="docutils literal notranslate"><span class="pre">openssl</span> <span class="pre">x509</span> <span class="pre">-inform</span> <span class="pre">pem</span> <span class="pre">-in</span> <span class="pre">public.pem</span> <span class="pre">-noout</span> <span class="pre">-text</span></code></p>
106+
</div></blockquote>
104107
</details></section>
105108
</section>
106109
<section id="usage">
@@ -125,11 +128,9 @@ <h3>Tunneling:<a class="headerlink" href="#tunneling" title="Permalink to this h
125128
<span class="c1"># Start tunneling</span>
126129
<span class="n">tunnel</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
127130

128-
<span class="c1"># set &#39;purge&#39; flag to &#39;True&#39; to delete AWS resources if configuration fails</span>
131+
<span class="c1"># set &#39;purge&#39; flag to &#39;True&#39; to reclaim AWS resources if configuration fails</span>
129132
<span class="c1"># tunnel.start(purge=True)</span>
130133

131-
<span class="c1"># sleep or do something else</span>
132-
133134
<span class="c1"># Stop tunneling - deletes all AWS resources acquired</span>
134135
<span class="n">tunnel</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span>
135136
</pre></div>
@@ -144,11 +145,11 @@ <h3>Tunneling:<a class="headerlink" href="#tunneling" title="Permalink to this h
144145
<section id="limitations">
145146
<h2>Limitations<a class="headerlink" href="#limitations" title="Permalink to this heading"></a></h2>
146147
<p>Currently <code class="docutils literal notranslate"><span class="pre">expose</span></code> cannot handle, tunneling multiple port numbers without modifying the following env vars in the <code class="docutils literal notranslate"><span class="pre">.env</span></code> file.</p>
147-
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>KEY_PAIR
148-
SECURITY_GROUP
149-
KEY_FILE
150-
CERT_FILE
151-
SERVER_INFO
148+
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>KEY_PAIR<span class="w"> </span><span class="c1"># SSH connection to AWS ec2</span>
149+
KEY_FILE<span class="w"> </span><span class="c1"># Private key filename for self signed SSL</span>
150+
CERT_FILE<span class="w"> </span><span class="c1"># Public certificate filename for self signed SSL</span>
151+
SERVER_INFO<span class="w"> </span><span class="c1"># Filename to dump JSON data with server configuration information</span>
152+
SECURITY_GROUP<span class="w"> </span><span class="c1"># Ingress and egress firewall rules to control traffic allowed via VPC</span>
152153
</pre></div>
153154
</div>
154155
</section>
@@ -194,7 +195,7 @@ <h3>Runbook<a class="headerlink" href="#runbook" title="Permalink to this headin
194195
</section>
195196
<section id="license-copyright">
196197
<h2>License &amp; copyright<a class="headerlink" href="#license-copyright" title="Permalink to this heading"></a></h2>
197-
<p>© Vignesh Sivanandha Rao</p>
198+
<p>© Vignesh Rao</p>
198199
<p>Licensed under the <a class="reference external" href="https://github.com/thevickypedia/expose/blob/main/LICENSE">MIT License</a></p>
199200
</section>
200201
</section>
@@ -238,7 +239,7 @@ <h3><a href="index.html">Table of Contents</a></h3>
238239
<div>
239240
<h4>Previous topic</h4>
240241
<p class="topless"><a href="index.html"
241-
title="previous chapter">Welcome to Expose’s documentation!</a></p>
242+
title="previous chapter">Expose - Expose a web service on localhost to public internet using AWS EC2</a></p>
242243
</div>
243244
<div role="note" aria-label="source link">
244245
<h3>This Page</h3>
@@ -271,14 +272,14 @@ <h3>Navigation</h3>
271272
<a href="py-modindex.html" title="Python Module Index"
272273
>modules</a> |</li>
273274
<li class="right" >
274-
<a href="index.html" title="Welcome to Expose’s documentation!"
275+
<a href="index.html" title="Expose - Expose a web service on localhost to public internet using AWS EC2"
275276
>previous</a> |</li>
276277
<li class="nav-item nav-item-0"><a href="index.html">Expose documentation</a> &#187;</li>
277278
<li class="nav-item nav-item-this"><a href="">Expose localhost using EC2</a></li>
278279
</ul>
279280
</div>
280281
<div class="footer" role="contentinfo">
281-
&#169; Copyright 2021, Vignesh Sivanandha Rao.
282+
&#169; Copyright 2021, Vignesh Rao.
282283
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.1.1.
283284
</div>
284285
</body>

docs/_sources/README.md.txt

+16-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Expose localhost using EC2
2-
Expose an app/api running on local host to public internet using AWS EC2
2+
Reverse proxy that creates a secure tunnel from public endpoint to locally running web service
33

44
### Requirements
55
- Access to an AWS account and [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions) configured.
@@ -29,7 +29,7 @@ The public DNS names for EC2 instances are long and messy. To avoid that, an `A`
2929

3030
:warning: &nbsp; Requires an active hosted zone on `route53`.
3131

32-
- **DOMAIN**: Domain name registered using `route53`. *Example: `mywebsite.com`*
32+
- **HOSTED_ZONE**: Hosted zone name registered using `route53`. *Example: `mywebsite.com`*
3333
- **SUBDOMAIN**: Sub-domain that has to be added for the domain name. *Example: `tunnel`*
3434

3535
&nbsp; &nbsp; &nbsp; &nbsp; :bulb: &nbsp; `tunnel.mywebsite.com` will be the endpoint to access the localhost from public internet.
@@ -47,17 +47,17 @@ The public DNS names for EC2 instances are long and messy. To avoid that, an `A`
4747

4848
:warning: &nbsp; Some web browsers might throw a warning and some might even block a self-signed certificate/private CA.
4949

50-
To manually generate a self-signed cert:
51-
52-
> `openssl req -newkey rsa:2048 -sha256 -nodes -keyout YOURPRIVATE.key -x509 -days 365 -out YOURPUBLIC.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=YOURDOMAIN.EXAMPLE"`
53-
54-
[OR]
55-
56-
Simply let `expose` create a self-signed SSL certificate and a private key. **(Default behavior)**
50+
`expose` creates a self-signed SSL certificate and a private key by default.
5751

5852
- **EMAIL_ADDRESS**: Email address to create the self-signed SSL and private key. Defaults to `[email protected]`
5953
- **ORGANIZATION**: Organization name for the certificate. Defaults to the AWS endpoint.
6054

55+
**Manually generate self-signed certificate**
56+
> `openssl req -newkey rsa:2048 -sha256 -nodes -keyout private.pem -x509 -days 365 -out public.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=tunnel.example.com"`
57+
58+
**To verify the generated certificate**
59+
> `openssl x509 -inform pem -in public.pem -noout -text`
60+
6161
</details>
6262

6363
### Usage
@@ -80,11 +80,9 @@ tunnel = expose.Tunnel()
8080
# Start tunneling
8181
tunnel.start()
8282

83-
# set 'purge' flag to 'True' to delete AWS resources if configuration fails
83+
# set 'purge' flag to 'True' to reclaim AWS resources if configuration fails
8484
# tunnel.start(purge=True)
8585

86-
# sleep or do something else
87-
8886
# Stop tunneling - deletes all AWS resources acquired
8987
tunnel.stop()
9088
```
@@ -100,11 +98,11 @@ tunnel.stop()
10098
### Limitations
10199
Currently `expose` cannot handle, tunneling multiple port numbers without modifying the following env vars in the `.env` file.
102100
```shell
103-
KEY_PAIR
104-
SECURITY_GROUP
105-
KEY_FILE
106-
CERT_FILE
107-
SERVER_INFO
101+
KEY_PAIR # SSH connection to AWS ec2
102+
KEY_FILE # Private key filename for self signed SSL
103+
CERT_FILE # Public certificate filename for self signed SSL
104+
SERVER_INFO # Filename to dump JSON data with server configuration information
105+
SECURITY_GROUP # Ingress and egress firewall rules to control traffic allowed via VPC
108106
```
109107

110108
## Coding Standards
@@ -149,6 +147,6 @@ pre-commit run --all-files
149147

150148
## License & copyright
151149

152-
&copy; Vignesh Sivanandha Rao
150+
&copy; Vignesh Rao
153151

154152
Licensed under the [MIT License](https://github.com/thevickypedia/expose/blob/main/LICENSE)

0 commit comments

Comments
 (0)