You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-41Lines changed: 46 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -18,8 +18,8 @@ For more information about the Email OAuth 2.0 Proxy, see the README in [simonro
18
18
19
19
I am paying ***approximately US$4.45 per month***, based on the prices I observed for my own usage in June 2022:
20
20
* $5/year paid upfront for a .link domain registered on Route 53
21
-
* As of 2022-06-11, the cheapest TLD is .click at $3/year *but it has no WHOIS privacy protection*.
22
-
* As of 2022-06-11, the second-cheapest TLD is .link at $5/year **and it has WHOIS privacy protection**.
21
+
* As of 2022-06-11, the cheapest TLD is .click at $3/year *but it has no WHOIS privacy protection*.
22
+
* As of 2022-06-11, the second-cheapest TLD is .link at $5/year **and it has WHOIS privacy protection**.
23
23
* $0.50/month for a Route 53 hosted zone
24
24
* $3.07/month for a t4g EC2 instance (cheapest instance type)
25
25
* $0.16/month for a 2GB EBS volume
@@ -30,57 +30,62 @@ I am paying ***approximately US$4.45 per month***, based on the prices I observe
30
30
### Pre-requisites:
31
31
32
32
* An AWS account, with the [AWS CLI](https://aws.amazon.com/cli/) configured on your local machine.
33
-
* You must have an AWS profile configured on your computer with admin access to your account, or at a minimum, sufficient privileges to manage the AWS resources used by this Terraform config.
34
-
* The default profile will be used, although [an alternative profile can be specified](https://github.com/michaelstepner/email-oauth2-proxy-aws/blob/6c31fef7bbc091b1f756ce969fb60bb951786e29/terraform/variables.tf#L5).
33
+
* You must have an AWS profile configured on your computer with admin access to your account, or at a minimum, sufficient privileges to manage the AWS resources used by this Terraform config.
34
+
* The default profile will be used, although [an alternative profile can be specified](https://github.com/michaelstepner/email-oauth2-proxy-aws/blob/6c31fef7bbc091b1f756ce969fb60bb951786e29/terraform/variables.tf#L5).
35
35
* A local installation of [Terraform](https://www.terraform.io/downloads).
36
36
37
37
### Installation steps:
38
+
38
39
1. Manually [register a domain using AWS Route 53](https://us-east-1.console.aws.amazon.com/route53/home#DomainRegistration).
39
-
* It may take a few minutes to a few hours for Amazon to complete the domain registration. There may be manual steps involved, such as validating your email address.
40
+
* It may take a few minutes to a few hours for Amazon to complete the domain registration. There may be manual steps involved, such as validating your email address.
41
+
40
42
2. From the AWS Console, navigate to [Route 53: Hosted Zones](https://us-east-1.console.aws.amazon.com/route53/v2/hostedzones#). Note down the "Hosted zone ID" for your chosen domain, which you will need in step 5.
43
+
41
44
3. Clone this repository onto your local computer.
45
+
42
46
4. Make a copy of the `terraform/config_example.tfvars` file, save it under a new name, and fill in the values with your own configuration settings.
43
-
* You can consult the readme in [simonrob/email-oauth2-proxy](https://github.com/simonrob/email-oauth2-proxy#readme) for more details about the `email_oauth2_proxy_config` settings.
44
-
* There are additional settings that can be configured, which may not be detailed in the example file. The full list of config settings is in [variables.tf](https://github.com/michaelstepner/email-oauth2-proxy-aws/blob/main/terraform/variables.tf).
47
+
* You can consult the readme in [simonrob/email-oauth2-proxy](https://github.com/simonrob/email-oauth2-proxy#readme) for more details about the `email_oauth2_proxy_config` settings.
48
+
* There are additional settings that can be configured, which may not be detailed in the example file. The full list of config settings is in [variables.tf](https://github.com/michaelstepner/email-oauth2-proxy-aws/blob/main/terraform/variables.tf).
49
+
45
50
5. Using a terminal, navigate to the `terraform` subdirectory of this repo and run the following commands, replacing ALL_CAPS values with your own:
6. You are now ready to create the AWS server. Using a terminal, in the `terraform` subdirectory of this repo, run the following command. Terraform will prompt you to review the resources that will be created, then type `yes` to confirm.
51
-
```
52
-
terraform apply -var-file=YOUR_CONFIG.tfvars
53
-
```
54
-
7. Using a terminal on your local computer, run `ssh -L 8080:127.0.0.1:8080 ec2-user@<PUBLIC_IP OR DOMAIN_FULL_NAME>`
55
-
* This will connect to the email-oauth2-proxy server, while also forwarding its port 8080 to your local computer for OAuth2 authentication purposes.
56
-
8. On the remote server you just SSH-ed into, run:
9. In your email client, configure SMTP using the server settings:
63
-
* Outgoing SMTP server: `DOMAIN_FULL_NAME`
64
-
* Port: `465`
65
-
* Username: `YOUR_EMAIL_ADDRESS`
66
-
* Password: `ANY_STRING_OF_YOUR_CHOICE`
67
-
10. When your email client attempts to connect to the SMTP server, you should see an authentication request appear in the email-oauth2-proxy server log via your SSH session. It will look like the text below. Copy and paste the URL from your terminal into your local browser, then complete the authentication prompts.
68
-
```
69
-
YYYY-MM-DD HH:MM:SS: Email OAuth 2.0 Proxy Local server auth mode: please authorise a request for account [email protected]
70
-
YYYY-MM-DD HH:MM:SS: Please visit the following URL to authenticate account [email protected]: URL
71
-
```
72
-
11. After you've completed the authentication prompts in your local browser, you should see the successful authentication appear in the email-oauth2-proxy server log via your SSH session. It will look like the text below. At this point you can close your local browser tab. Your email client should be able to successfully connect to the SMTP server and send outgoing emails.
12. In your terminal connected to the remote server, leave the email-oauth2-proxy server running while detaching from the tmux session by typing `Ctrl`+`b` then `d`. You can now log out of the remote server. It will continue running the email-oauth2-proxy server in the background.
57
+
```
58
+
terraform apply -var-file=YOUR_CONFIG.tfvars
59
+
```
60
+
61
+
7. Using a terminal on your local computer, run `ssh -L 8080:127.0.0.1:8080 ec2-user@<PUBLIC_IP OR DOMAIN_FULL_NAME> journalctl --follow -u emailproxy`
62
+
* This will display a live view of the email-oauth2-proxy logs, while also forwarding port 8080 on the server to your local computer for OAuth2 authentication purposes.
63
+
64
+
8. In your email client, configure SMTP using the server settings:
65
+
* Outgoing SMTP server: `DOMAIN_FULL_NAME`
66
+
* Port: `465`
67
+
* Username: `YOUR_EMAIL_ADDRESS`
68
+
* Password: `ANY_STRING_OF_YOUR_CHOICE`
69
+
70
+
9. When your email client attempts to connect to the SMTP server, you should see an authentication request appear in the email-oauth2-proxy server log via your SSH session. It will look like the text below. Copy and paste the URL from your terminal into your local browser, then complete the authentication prompts.
71
+
```
72
+
Email OAuth 2.0 Proxy Local server auth mode: please authorise a request for account [email protected]
73
+
Please visit the following URL to authenticate account [email protected]: URL
74
+
```
75
+
76
+
10. After you've completed the authentication prompts in your local browser, you should see the successful authentication appear in the email-oauth2-proxy server log via your SSH session. It will look like the text below. At this point you can close your local browser tab. Your email client should be able to successfully connect to the SMTP server and send outgoing emails.
11. You can now log out of the remote server by typing `Ctrl`+`c` to end your SSH session. It will continue running the email-oauth2-proxy server in the background.
77
82
78
83
### Limitations
79
84
80
85
* Your TLS certificate from Let's Encrypt will expire automatically after 90 days.
81
-
* After 60 to 90 days, you can renew the certificate by restarting the installation steps from Step 6 (`terraform apply ...`).
82
-
* If any settings (such as the TLS certificate) have changed, this will destroy the existing server and create a brand new server.
83
-
* You will therefore need to proceed through all the subsequent installation steps.
86
+
* After 60 to 90 days, you can renew the certificate by re-running installation step 6 (`terraform apply ...`).
87
+
* If any settings (such as the TLS certificate) have changed, this will destroy the existing server and create a brand new server.
88
+
* You should not need to re-authenticate (installation steps 7-11), because your OAuth 2.0 tokens are stored persistently in AWS Secrets Manager. Your authentication is not lost when the server is destroyed and re-created.
84
89
85
90
## Contributing
86
91
@@ -94,7 +99,7 @@ If you have a **feature request**, it is unlikely that I will be able to impleme
94
99
95
100
- [x] [Use certificate](https://github.com/simonrob/email-oauth2-proxy/blob/b26c7b4d25f431e2a1ea12a30667cb9746401211/emailproxy.config#L28) to secure the connection between email client and proxy server
96
101
- [x] Add support for storing OAuth2 tokens using a secrets manager (e.g. AWS Secrets Manager) instead of locally, so it persists across servers
97
-
-[][Automatically launch](https://github.com/simonrob/email-oauth2-proxy/issues/2#issuecomment-839713677)`email-oauth2-proxy`and configure OAuth2 token without SSHing into the server
102
+
- [x] [Automatically launch](https://github.com/simonrob/email-oauth2-proxy/issues/2#issuecomment-839713677) `email-oauth2-proxy` on server via `systemctl`
98
103
- [ ] Add support for automatically rotating TLS certificate, which expires automatically after 90 days
0 commit comments