jackjoe / mailgun_logger

Simple Mailgun log persistence in Phoenix/Elixir
MIT License
74 stars 10 forks source link

Mailgun Logger Setup #17

Closed legalassoc closed 2 years ago

legalassoc commented 2 years ago

We are looking to setup MG Logger and need a little help troubleshooting.

Current steps we have taken.. Setup Linux EC2 on AWS Installed docker and docker compose Ran Docker Compose and copied the text from github into docker-compose.yml Ran docker-compose up.. Got a success message with MailgunLogger running If I go to the EC2 Public IPv4 address and add the :5050 at the end, the browser just spins.

This gave the following output...

[ec2-user@ip-172-31-46-57 ~]$ docker compose up
docker: 'compose' is not a docker command.
See 'docker --help'
[ec2-user@ip-172-31-46-57 ~]$ docker-compose up
[+] Running 2/2
 ⠿ Container ec2-user-db-1   Recreated                                     1.5s
 ⠿ Container ec2-user-web-1  Recreated                                    10.3s
Attaching to ec2-user-db-1, ec2-user-web-1
ec2-user-db-1   | 2022-04-13 11:57:41+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.28-1debian10 started.
ec2-user-db-1   | 2022-04-13 11:57:41+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
ec2-user-db-1   | 2022-04-13 11:57:41+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.28-1debian10 started.
ec2-user-db-1   | 2022-04-13T11:57:41.788115Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.28) starting as process 1
ec2-user-db-1   | 2022-04-13T11:57:41.798175Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
ec2-user-db-1   | 2022-04-13T11:57:41.979531Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
ec2-user-db-1   | 2022-04-13T11:57:42.186708Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
ec2-user-db-1   | 2022-04-13T11:57:42.186823Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
ec2-user-db-1   | 2022-04-13T11:57:42.188579Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
ec2-user-db-1   | 2022-04-13T11:57:42.222528Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.28'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.
ec2-user-db-1   | 2022-04-13T11:57:42.223223Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
ec2-user-web-1  | |> MIGRATE_AND_SEED
ec2-user-web-1  | |> Starting dependencies...
ec2-user-web-1  | |> Starting repos...
ec2-user-web-1  | 11:57:44.357 [info] Migrations already up
ec2-user-web-1  | |> Running seed script...
ec2-user-web-1  | |> Success!
ec2-user-web-1  | 11:57:51.717 [info] Running MailgunLoggerWeb.Endpoint with cowboy 2.9.0 at 0.0.0.0:5050 (http)
ec2-user-web-1  | 11:57:51.731 [info] Access MailgunLoggerWeb.Endpoint at http://localhost
legalassoc commented 2 years ago
[ec2-user@ip-172-31-46-57 ~]$ curl http://0.0.0.0:5050
<html><body>You are being <a href="/setup">redirected</a>.</body></html>[ec2-user@ip-172-31-46-57 ~]$ 
jeroenbourgois commented 2 years ago

Can you please surround all code output in a code block? You can just edit your post, select the code and use the '<>' icon, or just use backticks. See the GitHub docs.

OT: Seems everything is working on the tool side! What is the IP of your instance? The curl to the localhost seems fine, the redirect is to be expected. Can you tweak the command a bit to output the headers?

curl -I http://0.0.0.0:5050

My estimation is that everything is working just fine, you will need to add a reverse proxy to your instance in order to redirect traffic to the application. There are a ton of examples on the net on how to do that. What is your OS? Debian, or the stock Amazon linux. Should not really matter.

Try following this link - you can skip most of it, you just need the nginx bit.

legalassoc commented 2 years ago

The public IPv4 of my instance is... 3.144.81.51

[ec2-user@ip-172-31-46-57 ~]$ curl -I http://0.0.0.0:5050
HTTP/1.1 302 Found
cache-control: max-age=0, private, must-revalidate
content-length: 72
content-type: text/html; charset=utf-8
cross-origin-window-policy: deny
date: Wed, 13 Apr 2022 12:59:48 GMT
location: /setup
server: Cowboy
x-content-type-options: nosniff
x-download-options: noopen
x-frame-options: SAMEORIGIN
x-permitted-cross-domain-policies: none
x-xss-protection: 1; mode=block
jeroenbourgois commented 2 years ago

@legalassoc ok, looking at the redirect header, the app is working. You are being redirected to the /setup path which is normal. Since I can ping your IP but not access the web app, you will need to setup a webserver. Right of the bat, you could just install nginx and run it right out of the box. You should be able to serve a very basic html page at your IP adres (or better: point a url to the machine). Can you try that first?

legalassoc commented 2 years ago

Got it @jeroenbourgois, I was able to get nginx installed and can see it here... http://3.144.81.51/ I also created an inbound rule to open up port 5050 but when I go http://3.144.81.51:5050/ here it says it can't be reached. Do you have any suggestions on my next steps?

Thank you also for the help and input!

[ec2-user@ip-172-31-46-57 ~]$ curl http://localhost:5050
curl: (7) Failed to connect to localhost port 5050 after 0 ms: Connection refused
[ec2-user@ip-172-31-46-57 ~]$ curl http://0.0.0.0:5050
curl: (7) Failed to connect to 0.0.0.0 port 5050 after 0 ms: Connection refused
[ec2-user@ip-172-31-46-57 ~]$ 
legalassoc commented 2 years ago

Solved! We are up and running, thank you for all the help!

jeroenbourgois commented 2 years ago

Niiiice!! I hope the tool will be useful. On 13 Apr 2022, 21:03 +0200, legalassoc @.***>, wrote:

Solved! We are up and running, thank you for all the help! — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

jeroenbourgois commented 2 years ago

@legalassoc out of interest: how is the app running? I don't think nginx is serving the requests, but Cowboy (the webserver of the Mailgun Logger project) is, from docker. If you app is for internal use this is fine, but if you were to add a domain to it you might need nginx to forward. But if you don't need it you can uninstall nginx altogether.